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("\t\t金额不足,支付失败");
}
else{
System.out.println("************消费单************");
System.out.println("购买物品\t单价\t个数\t金额");
System.out.println(name1+"\t"+price1+"\t"+num1+"\t"+sum1);
System.out.println(name2+"\t"+price2+"\t"+num2+"\t"+sum2);
System.out.println(name3+"\t"+price3+"\t"+num3+"\t"+sum3);
System.out.println("============================");
System.out.println("消费总金额\t\t\t"+money);
System.out.println("实际交费\t\t\t"+allSum);
System.out.println("找钱\t\t\t"+p);
}
input.close();
}
}