I don't have any idea how to display the largest and smallest number after the user enter -1.
Note: I also have to display the sum of all of this number and the average of this sum.
Here's my code so far:
public static void main(String[] args) {
// store
int cnt = 0;
int acumulator = 0;
int larger = 0;
int smaller = 0;
int number;
// inputs
System.out.println("enter the number all the number");
Scanner kb = new Scanner(System.in);
number = kb.nextInt();
// loop
while (number != -1) {
acumulator += number;
number = kb.nextInt();
cnt++;//
}
double average = (acumulator / cnt);
System.out.println(" The total of your number is=" + acumulator);
System.out.println(" The average of your number is=" + average);
}
cntandcountis and why only one is used? :-)count? :-)