package card; import java.util.Scanner; public class Shoping { public static void main(String[] args) { // TODO Auto-generated method stub Scanner input = new Scanner(System.in); System.out.println("依次输入购买物品,单价,个数:"); //第一件商品,单价,个数 String name1 = input.next(); float price1 = input.nextFloat(); int num1 = input.nextInt(); float sum1 = price1*num1; //第二件商品,单价,个数 String name2 = input.next(); float price2 = input.nextFloat(); int num2 = input.nextInt(); float sum2 = price2*num2; //第三件商品,单价,个数 String name3 = input.next(); float price3 = input.nextFloat(); int num3 = input.nextInt(); float sum3 = price3*num3; System.out.println("实际交费:"); float money = input.nextFloat(); //交费 float allSum = sum1+sum2+sum3; //消费总金额 float p=money-allSum; //找零 if(p<0){ System.out.println(" 金额不足,支付失败"); } else{ System.out.println("************消费单************"); System.out.println("购买物品 单价 个数 金额"); System.out.println(name1+" "+price1+" "+num1+" "+sum1); System.out.println(name2+" "+price2+" "+num2+" "+sum2); System.out.println(name3+" "+price3+" "+num3+" "+sum3); System.out.println("============================"); System.out.println("消费总金额 "+money); System.out.println("实际交费 "+allSum); System.out.println("找钱 "+p); } input.close(); } }