Im trying to write a code that uses 3 methods that follows specific guide lines. These are the guide lines:
The program uses methods to:
Get the numbers entered by the user
Calculate the average of the numbers entered by the user
Print the results with the whole number, a decimal, and two decimal positions
The first method should take no arguments and return a String of numbers separated by spaces.
The second method should take a String as its only argument and return a double (the average).
The third method should take a String and a double as arguments but have no return value.
For example, if the user input is... 20 40 60 80 100
...the program should give as output... The average of the numbers 20 40 60 80 100 is 60.00
The first method does get a line of numbers form the user but I'm stumped as to how to writew a method that calualtes the average for thos numbers. I know the second method would have to have a sum oif the numbers entered and then that sum be divided by the numer of numbers entered. I dont how sum the numbers entered since thewy are in a string and dont know how to find the average, I hough of using .length() as a way toi find that average but that didnt work. Any iodeas?