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); } }
java-第七章-数组-购物金额结算,布布扣,bubuko.com
原文地址:http://wenwen520.blog.51cto.com/8956560/1420875