import java.util.*; public class Pay { public static void main(String[] args) { Scanner input =new Scanner(System.in); System.out.println("************消费单************"); System.out.println("购物物品\t单价\t个数\t金额"); System.out.println("T桖\t¥245\t2\t¥490"); System.out.println("网球鞋\t¥570\t1\t¥570"); System.out.println("网球拍\t¥320\t1\t¥320"); System.out.println("\n\n折扣:\t8折"); int Txue =245; int wangqiu = 570 ; int qiupai = 320; int Txueg =2 ; int wangqiug =1 ; int qiupaig =1 ; double dz =0.8; double zje = (Txue * Txueg + wangqiu * wangqiug + qiupai*qiupaig )*dz ; System.out.println("消费金额为\t" + zje ); int jiaofei ; System.out.println("请输入金额:¥"); jiaofei = input.nextInt();//可以输入金额 System.out.println("实际交费\t\t¥:"+jiaofei);//确认金额 double zhaoqian =(jiaofei - zje ); System.out.println("找钱\t\t¥:"+ zhaoqian); //用实际交费的金额减去消费金额所得 Money int jifen = (int)zje * 3 / 100 ; //把消费金额转换成整数型 int 在* 3 / 100 System.out.println("\n本次购物所获的积分是:" + jifen); } }
Java-第二章-上机练习2我行我素购物管理系统,布布扣,bubuko.com
原文:http://lianlian520.blog.51cto.com/9018432/1423985