Question: Assignment 6: Arrays Write a class Summer that gets a list of floating point numbers as its command line arguments. For example, the user might

Assignment 6: Arrays

Write a class Summer that gets a list of floating point numbers as its command line arguments. For example, the user might type

 java Summer 1.3 435.78 -22.7 88

The class will read the numbers and print their sum. The class should implement and use a method

 double sum(double[] values)

Note that the method sum should not do any printing.

Write a similar class that gets a set of Strings from the command line. Store the Strings in an array. Implement a method reverse() that will reverse the elements of an array, and use it to show the reversed array.

Note: on #2: We want the method reverse to have this signature:

 void reverse(String[] strings)

That is, the reverse method will reverse the values in the array, but does not itself return a value. The easiest way to do that is to copy the values parameter to another local array (but in reverse) and then copy back onto the original array. A more efficient and sophisticated way to do it is to figure out how to rearrange the values in the array without creating a second arraythat is the bonus version of the problem.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!