12

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("无换购项目!");
		}
	}

}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值