我有几天试图弄清楚如何解决这个问题,但我找不到解决方案。我已经尝试了所有建议,但我仍然不知道如何显示最低数字。
import java.util.Scanner;
public class finalname {
public static void main(String args[]) {
Scanner kb = new Scanner(System.in);
System.out.println("How Many Numbers You Want To Enter: ");
int total = kb.nextInt();
int input = 0;
int sum = 0;
int average=0;
int max = Integer.MIN_VALUE;
int min = Integer.MAX_VALUE;
while (input < total) {
input++;
System.out.println("Enter " + input + ". Operand: ");
sum += kb.nextInt();
if (min >= sum)
{
min = sum;
}
if (max <= sum)
{
max = sum;
}
average = ( sum ) / ( input);
}
System.out.println("The sum is " + sum + ".");
System.out.println("The avg " + average);
System.out.println("The highest number " + max);
System.out.println("The the lowest number " + min);
}
}