/**接收用户输入的若干整数,以一个-1标志输入结束,
* 求出其中的最大值、最小值和平均值
**/
import java.util.*;public class FirstProgram{ public static void main (String args[]) { int x; int max = -2147483648; int min = 2147483647; int n = 0; int sum = 0; Scanner in = new Scanner (System.in); System.out.print("输入整数:"); x = in.nextInt(); while (x != -1) { sum += x; n++; if (x > max) max = x; if (x < min) min = x; System.out.print("输入下一个整数:"); x = in.nextInt(); } System.out.println("Max: " + max); System.out.println("Min: " + min); System.out.print("Average: "); System.out.printf("%.2f", (double)sum / (double)n); }}