Hi
I have this problem where I tell the user to prompt 10 integers separated with spaces. And then I have to output the same numbers the user entered and then output max and min numbers. So How can I get the maximum value of these multiple integers?
This is my code:
System.out.println("Enter ten integers separated with spaces:");
int num1 = scan.nextInt();
int num2 = scan.nextInt();
int num3 = scan.nextInt();
int num4 = scan.nextInt();
int num5 = scan.nextInt();
int num6 = scan.nextInt();
int num7 = scan.nextInt();
int num8 = scan.nextInt();
int num9 = scan.nextInt();
int num10 = scan.nextInt();
int Sum = num1+num2+num3+num4+num5+num6+num7+num8+num9+num10;
int Average = (Sum/10);
int counter = 0;
System.out.println("The numbers you entered are: ");
while(counter<10){
System.out.print("The numbers you entered are:\n"+num1+" "+num2+" "+num3+" "+num4+" "+num5+" "+num6+" "+num7+" "+num8+" "+num9+" "+num10);
counter++;
}
}
}
I have to use while loop and/or do-while loop to solve it. So don't tell me to use for loop. :)
Any help?:confused:
Thanks.