CS101 – 955

Instructions:

 

Don't use plagiarized sources. Get Your Custom Essay on
CS101 – 955
Just from $13/Page
Order Essay
  • Solve questions 1 and 2 for points on assignment 5

 

  • Question 3 is a bonus question worth 5 points that I will add to your lowest quiz grade to reach a maximum of 5 points.

 

  • If you use any external resources:
    • Add the reference
    • DO NOT COPY THE CODE

 

Questions

 

  1. (10 points) Identify and fix the errors in the following code. Hint: there are five errors. (you must show the error and the fix):

 

1 public class DiscoverErrors {

2              public static void main(String[] args) {

3                             double[100] localArray;

5                              for (int i = 0; i < localArray.length(); i++);

6                                             localArray(i) = Math.random * 100;

7             }

8 }

 

  1. (10 points) Use the arraycopy method to copy the array below to a target array The program should then print the values of targetArray. (you must show the code and the output):

 

int[] sourceArray = {32, 54, 67, 80};

 

 

  1. (Bonus: 5 points) Write a program for a restaurant that is used to compute the total expenses of the restaurant, their average, maximum expense item, minimum expense item and then prints the results. The program should do the following:

 

  1. Ask the user for the number of expense items they would like to add. Your code should show something as the following:

 

Please enter the number of expense items: 3

 

  1. Then, it asks the user to enter the expenses each separated by a space. Imagine they are entering them as the cost of a water bill, electricity bill, rent, … so your code should show something similar to the following:

 

Please enter each expense item separated by space: 10.5 23.6 1009.54

 

Hint: Uses an array to store the values entered by the user

 

  1. Write a method called printValue that you can reuse to print all the values in steps (e, f, g, and h). The method should take as input a string which is the name of the value to print and a value. An example print statement that you can use inside the method printValue where valueName is a String variable and value is a variable of data type double:

 

System.out.println(“The “ + valueName + “ is “ + value);

 

Hint: the method does not return a value, it only prints a message

 

  1. Compute the total cost which is the sum of all elements/expense items and print it using the method printValue

 

  1. Compute the maximum value of an expense item and print it using the method printValue

 

  1. Compute the minimum value of expense items and print it using the method printValue

 

  1. Write a method that returns the average of all expenses. It should take as input: the sum and the number of items. Then, print the average using the method printValue

 

  1. Write a method that prints the expense items in reverse. The method should take as input an array. In other words, using the example values shown in step b, your program should print something as the following:

 

The items you entered are: 1009.54 23.6 10.5

 

 

 

The Homework Labs
Calculate your paper price
Pages (550 words)
Approximate price: -

Our Advantages

Plagiarism Free Papers

We ensure that all our papers are written from scratch. We deliver original plagiarism-free work. To guarantee this, we submit all work alongside a plagiarism report.

Free Revisions

All our papers are completed and submitted before the deadline. We ensure this to provide you with enough time to go through the work and point out any sections or topics that may need revision or polishing. We provide unlimited revision services for free.

Title-page

All papers have a title page providing your personal and institutional information. We do not charge you for this title page.

Bibliography

All papers have a bibliography or references page. This page is a requirement for academic and professional documents. We provide this page at no cost for all our papers.

Originality & Security

At Thehomeworklabs, we guarantee the confidentiality and security of your information. We value our clients and take confidentiality seriously. All personal information is treated with confidentiality and stored safely to ensure that no third parties gain access to it. We also provide original work and attach an originality/plagiarism report alongside all papers.

24/7 Customer Support

Our customer support team is available 24/7 to provide you with any necessary assistance when you need it. You can contact us at any time, day or night, via email or through the live chat button.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

Our Services

We provide our customers with the best experience in the academic and business writing field.

Pricing

Flexible Pricing

We provide the best quality of service at affordable prices. We also allow our clients to make partial payments for their orders. You can also contact our customer support team in case you need to discuss a different payment plan.

Communication

Admission help & Client-Writer Contact

We realize that sometimes clarification is necessary to ensure that quality work is done. Therefore, we provide a button for clients and writers to communicate in case some clarification is needed.

Deadlines

Paper Submission

We ensure that we submit all papers ahead of their respective deadlines. This allows you to go through the documents and request any revision, corrections, or polishing before the paper is due.

Reviews

Customer Feedback

We encourage customer feedback, positive or negative. We can identify the various areas that we need to improve to provide even better services through your feedback. Please feel free to give us feedback.