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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started