1 public static void main(String[] args) { 2 double[] array = new double[5]; 3 Scanner input = new Scanner(System.in); 4 System.out.println("请输入会员本月的消费记录:"); 5 for (int i = 0; i < array.length; i++) { 6 System.out.print("请输入第" + (i + 1) + "笔购物金额:"); 7 array[i] = input.nextDouble(); 8 } 9 System.out.println(" 序号 金额(元)"); 10 double sum = 0; 11 for (int j = 0; j < array.length; j++) { 12 sum += array[j]; 13 System.out.println((j + 1) + " " + array[j]); 14 } 15 System.out.println("总金额 " + sum); 16 17 }