I'm trying to learn how to write code in order to find the average of numbers I enter in my program, as well as every time I enter a number it records how many I have typed in, and finally the sum of all the numbers I have entered each time. I'm wondering if someone can help me start this off, as I have no where to begin. I know my program will need to have atleast two variables, but I don't know how to implement them.
This is the code I have so far, I am having trouble implementing finding average, total, and count.
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);
}
}