Answer:
import java.util.Scanner;
class Main {
static final int TOTAL = 10;
public static void main (String args[])
{
Scanner input = new Scanner(System.in);
int largest = 0;
for(int count=1; count<=TOTAL; count++) {
System.out.printf("Enter number %d of %d : ", count, TOTAL);
int number = input.nextInt();
if (count == 1) {
largest = number;
} else {
largest = Math.max(largest, number);
}
}
System.out.printf("The largest number is %d\\", largest);
input.close();
}
}
Step-by-step explanation:
You have to pay special attention to the initialization of largest, because the initialized value should not be part of the competition of which number is the largest. That's why if (count==1) is a special case.