import java.util.Scanner;
public class A02 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input= new Scanner (System.in);
double number [] = new double [5];
double sum=0;
for (int i = 0; i < number.length; i++) {
System.out.println("请输入第"+(i+1)+"笔购物:");
number[i]=input.nextDouble();
}
System.out.println("序号\t金额(元)");
for (int i = 0; i < number.length; i++) {
System.out.println((i+1)+"\t"+number[i]);
sum+=number[i];
}
System.out.println("总金额\t"+sum);
}
}
转载于:https://blog.51cto.com/765133133/1420875