import java.util.Scanner;
class CalcAvg{
public static void main (String args[]){
Scanner s = new Scanner(System.in);
int sum = 0;
int avg = 0;
for(int i = 0; i < 10; i++){
System.out.println("Enter a number: ");
int num = s.nextInt();
sum = sum+num;
}
avg = sum/10;
System.out.println("The sum is: " + sum);
System.out.println("The average is: " + avg);
}
}
So I've written this code, its correct, though I would like to have the user input an unknown amount of numbers instead of 10 then stopping it by hitting a character or enter. How do I do that?
Thanks