/**
*
*/
public class Shopping {
public static void main(String [] args) {
System.out.println("\t\t欢迎使用我行我素管理系统1.0版");
System.out.println("* * * * * * * * * * * * * * * * * * * * * * * * * * * * *");
System.out.println("\t\t\t1.登录系统");
System.out.println("\t\t\t2.更改管理员密码");
System.out.println("\t\t\t3.退出");
System.out.println("* * * * * * * * * * * * * * * * * * * * * * * * * * * * *");
System.out.print("请输入您的选择:");
java.util.Scanner input = new java.util.Scanner(System.in);
int choice1 = input.nextInt();
if(choice1 == 1){
System.out.println("\t\t欢迎使用我行我素管理系统");
System.out.println("* * * * * * * * * * * * * * * * * * * * * * * * * * * * *");
System.out.println("\t\t\t1.客户信息管理");
System.out.println("\t\t\t2.购物结算");
System.out.println("\t\t\t3.真情回馈");
System.out.println("\t\t\t4.返回上一级");
System.out.println("* * * * * * * * * * * * * * * * * * * * * * * * * * * * *");
System.out.print("请输入您的选择:");
//java.util.Scanner input = new java.util.Scanner(System.in);
int choice2 = input.nextInt();
if(choice2 == 2){
System.out.println("商城现有商品如下:");
System.out.println("商品编号\t\t商品名称\t\t商品价格");
System.out.println("1\t\t\t云南白药\t\t¥18.00");
System.out.println("2\t\t\t小米手机\t\t¥1,998.00");
System.out.println("3\t\t\t小黑\t\t\t¥4,998.00");
System.out.println("4\t\t\t拖鞋\t\t\t¥25.80");
System.out.println("5\t\t\t酱油\t\t\t¥5.60");
System.out.println("6\t\t\t汽车模型\t\t¥350.00");
System.out.println("7\t\t\t坦克模型\t\t¥400.00");
System.out.println("8\t\t\t玩具枪\t\t¥99.80");
System.out.print("请输入您要购买的产品编号:");
//java.util.Scanner input = new java.util.Scanner(System.in);
int choice3 = input.nextInt();
System.out.print("请输入您要购买的产品数量:");
//java.util.Scanner input = new java.util.Scanner(System.in);
int choice4 = input.nextInt();
double sum = 0;
double a = 0;
String str = "输入错误";
switch (choice3) {
case 1:
sum = choice4 * 18;
a = 18;
str = "云南白药";
break;
case 2:
sum = choice4 * 1998;
a = 1998;
str = "小米手机";
break;
case 3:
sum = choice4 * 4998;
a = 4998;
str = "小黑";
break;
case 4:
sum = choice4 * 25.8;
a = 25.8;
str = "拖鞋";
break;
case 5:
sum = choice4 * 5.6;
a = 5.6;
str = "酱油";
break;
case 6:
sum = choice4 * 350;
a = 350;
str = "汽车模型";
break;
case 7:
sum = choice4 * 400;
a = 400;
str = "坦克模型";
break;
case 8:
sum = choice4 * 99.8;
a = 99.8;
str = "玩具枪";
break;
default:
break;
}
System.out.println("尊敬的用户:小猫");
System.out.println("产品名称\t\t产品单价\t\t购买数量");
System.out.println(str + "\t\t" + a +"\t\t\t" + choice4);
System.out.println("您购买的产品总价为:¥" + sum);
System.out.println("按您当前的积分,您的折扣是:0.85");
double b;
b = 0.85 * sum;
System.out.println("您的应付款为:¥" + (float)b);
System.out.print("请付款:");
//java.util.Scanner input = new java.util.Scanner(System.in);
int num = input.nextInt();
if(num < sum){
System.out.println("系统拒绝,请重新宠幸本系统!");
} else {
System.out.println("付款成功!");
System.out.println("找零:¥" + (float)(num - b));
System.out.println("欢迎下次光临!");
}
} else {
System.out.println("功能正在升级中.........");
}
} else {
System.out.println("功能正在升级中.........");
}
}
}
程序运行结果如下: