Hi, I'm completely new to Java and having some trouble basically understanding everything. I have some code and am wondering how to edit it in order to make some questions that I'm being asked to work.
Here's the code:
import java.util.*; // for class Scanner
public class Copy {
public static void main(String[] args) {
Scanner stdin = new Scanner(System.in);
System.out.println("Ready to copy numbers!\n" +
"Enter Control-Z when done!");
double num;
while(stdin.hasNext()) {
num = stdin.nextDouble();
System.out.printf("%.2f\n", num);
}
System.out.println("Goodbye!");
System.exit(0);
}
}
Here is what I'm being asked:
Modify the above program to print the
a. Count of numbers input
b. The total of the numbers input
c. The average of the numbers input
Hint: Your program will need to have 2 variables, say n and total, that keep a running count of the
number of values read and the total up to that point.
Any help would be highly appreciated, thanks so much !