package hanjiazy2;
import java.util.Scanner;
public class hanjia2 {
public static void main(String[] args) {
Scanner x=new Scanner(System.in);
System.out.print("请输入消费金额:");
double money=x.nextDouble();
double extar=0;
int choice=x.nextInt();
if(money>=50){
System.out.println("是否参加优惠换购活动:");
System.out.println("1:满50元,加2元换购百事可乐饮料1瓶");
System.out.println("2:满100元,加3元换购500ml可乐一瓶");
System.out.println("3:满100元,加10元换购5公斤面粉");
System.out.println("4:满200元,加10元可换购1个苏泊尔炒菜锅");
System.out.println("5:满200元,加20元可换购欧莱雅爽肤水一瓶");
System.out.println("0:不换购");
System.out.print("请选择:");
if(x.hasNext()==true){
choice = x.nextInt();
switch(choice){
case 1:
if(money>=50){
extar=2;
}
break;
case 2:
if(money>=100){
extar=3;
}
break;
case 3:
if(money>=100){
extar=10;
}
break;
case 4:
if(money>=200){
extar=10;
}
break;
case 5:
if(money>=200){
extar=20;
}
break;
default:
break;
}
}else{
System.out.print("请输入正确的数字");
}
}
double total = money + extar;
System.out.println("本次消费总金额:"+ total);
if(choice == 1){
System.out.println("成功换购:" + "百事可乐饮料1瓶。");
}else if(choice ==2 ){
System.out.println("成功换购:" + "500ml可乐一瓶。");
}else if(choice == 3){
System.out.println("成功换购:" + "5公斤面粉。");
}else if(choice == 4){
System.out.println("成功换购:" + "1个苏泊尔炒菜锅。");
}else if(choice == 5){
System.out.println("成功换购:" + "欧莱雅爽肤水一瓶。");
}else {
System.out.println("无换购项目!");
}
}
}
12
最新推荐文章于 2024-04-16 22:57:17 发布