import java.util.Scanner; /** * @author 蓝色以太 * 完成打印购物小票并计算积分 */ public class ShoppingReceipt { public static void main(String[] args) { Scanner sc=new Scanner(System.in); final int NUM1=245,NUM2=570,NUM3=320; System.out.println("请输入购买T恤数量:"); int num1=sc.nextInt(); int sum1=num1*NUM1; System.out.println("请输入购买网球鞋数量:"); int num2=sc.nextInt(); int sum2=num2*NUM2; System.out.println("请输入购买网球拍数量:"); int num3=sc.nextInt(); int sum3=num3*NUM3; int sum=sum1+sum2+sum3; System.out.println("********销售单********"); System.out.println("购买物品\t单价\t数量\t金额"); System.out.println("T恤\t¥"+NUM1+"\t"+num1+"\t"+sum1); System.out.println("网球鞋\t¥"+NUM2+"\t"+num2+"\t"+sum2); System.out.println("网球拍\t¥"+NUM3+"\t"+num3+"\t"+sum3); System.out.println("消费总金额:"+sum+"元"); System.out.println("获得积分:"+3*(sum/100)); } }
时间: 2024-10-13 12:52:28