for循环购物清单
//实现如图的购物清单
package ch06; import java.util.Scanner; /** * Created by liwenj on 2017/7/18. */ public class test12 { public static void main(String[] args) { double sum=0; System.out.println("消费清单"); Scanner input=new Scanner(System.in); double[] score=new double[5]; for(int i=0;i<5;i++){ System.out.print("请输入第"+(i+1)+"笔金额"); score[i]=input.nextDouble(); sum=sum+score[i]; } System.out.println("序号\t"+""+"金额\t"); for(int i=0;i<5;i++){ System.out.println((i+1)+"\t"+""+score[i]); } System.out.println("总金额"+sum); } }