我有这个程序,它使用用户输入来查找输入数字的总和,以及最小的数字和用户输入的整数数量。
public static void main(String args[])
{
int numOfints = 0;
int numberin;
int sum = 0;
int small;
Scanner input = new Scanner(System.in);
System.out.print("Please enter the numbers. <-999 to stop>: ");
System.out.print("Please enter the first number: ");
numberin = input.nextInt();
small = numberin;
while(numberin!=-999)
{
numOfints++;
sum+=numberin;
}
if (numberin >0)
{
System.out.println("Total number of numbers inputted was" +numOfints);
System.out.println("The sum of these numbers is " + sum);
System.out.println("The smallest number in the set is" + small);
}
else
System.out.println("The number set is empty, therefore no calculations can be performed.");
}
}
{
但是,当我运行程序时,唯一出现的是
c:\jwork>java lab7a
Please enter the numbers; <-999 to stop>: Please enter the first number: 1
_
并且它不允许用户再输入。为什么程序不会继续?