Question
Create, using NetBeans, a complete Java program called CalcAvg according to the following guidelines. (This program requires the use of arrays.) The program prompts the
Create, using NetBeans, a complete Java program called CalcAvg according to the following guidelines. (This program requires the use of arrays.) The program prompts the user for five to ten numbers all on one line, separated by spaces, calculates the average of those numbers, and displays the numbers and their average to the user. 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. The first method should take no arguments and return an array of doubles that the user entered. The second method should take an array of doubles (the return value of the first method above) as its only argument and return a double (the average). The third method should take an array of doubles and a (single) double value as arguments but have no return value. For example: If the user input is: 40 60 20 80 100 Then the program should give as output: The average of the numbers 40.00, 60.00, 20.00, 80.00, and 100.00 is 60.00.
The following was provided to get me started but I'm still confused. I also need help on how to print out 40.00, 60.00, 20.00, 80.00, and 100.00 is 60.00. with commas and the word "and" before the last number.
public static void main(String [ ] args) {
double[ ] numbers = getNumbers();
double average = computeAverage(numbers);
printResults(numbers, average);
}
public static double [ ] getNumbers ( ) {
}
public static double computeAverage(double[ ] nums) {
}
public static void printResults(double[ ] numbers, double avg) {
}
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