zoukankan      html  css  js  c++  java
  • 21.升级我行我素管理系统实现换购的功能

    //本代码为测试代码,所以存在错误
    //出错的演练,当输入200,case6时不报错。
    //等待更新。
    import java.util.Scanner;

    public class Main {
    public static void main(String[] args) {
    System.out.println("请输入消费金额");
    Scanner input = new Scanner(System.in);
    Double money = input.nextDouble();
    String buHuanGou = ("很抱歉,您不满足换购要求"); // buHuanGou--当客户换购时,输出空,即为不输出
    System.out
    .println("是否参加换购活动\n1.满50元,加两元换购百事可乐饮料一瓶\n2.满100元,加三元换购500ml百事可乐\n3.满一百元,加10元换购五公斤面粉\n4.满200元,加十元换购一个苏泊尔炒饭锅\n5.满200元,加20元,换购欧莱雅香水爽肤水\n0.不换购\n请选择:");
    int num = input.nextInt();

    if (money >= 100 && money < 200) {

    switch (num) {
    case 0:
    System.out.println("您选择了不换购");
    buHuanGou = "";
    break;
    case 1:
    money = money + 2;
    System.out.println("本次消费为" + money + "\n成功换购" + num);
    buHuanGou = "";
    break;
    case 2:
    money = money + 3;
    System.out.println("本次消费为" + money + "\n成功换购" + num);
    buHuanGou = "";
    break;
    case 3:
    money = money + 10;
    System.out.println("本次消费为" + money + "\n成功换购" + num);
    buHuanGou = "";
    break;
    }

    }
    if (money < 50 && num == 0) {
    buHuanGou = "";
    }

    if (money >= 50 && money < 100) {

    switch (num) {
    case 0:
    System.out.println("您选择了不换购");
    buHuanGou = "";
    break;
    case 1:
    money = money + 2;
    System.out.println("本次消费为" + money + "\n成功换购" + num);
    break;

    }

    }

    if (money >= 200) {
    switch (num) {
    case 0:
    System.out.println("您选择了不换购");
    buHuanGou = "";
    break;
    case 1:
    money = money + 2;
    System.out.println("本次消费为" + money + "\n成功换购" + num);
    break;
    case 2:
    money = money + 3;
    System.out.println("本次消费为" + money + "\n成功换购" + num);
    break;
    case 3:
    money = money + 10;
    System.out.println("本次消费为" + money + "\n成功换购" + num);
    break;

    case 4:
    money = money + 10;
    System.out.println("本次消费为" + money + "\n成功换购" + num);
    break;

    case 5:
    money = money + 20;
    System.out.println("本次消费为" + money + "\n成功换购" + num);
    break;
    }
    } else {
    if (num > 5 || num < 0) {
    buHuanGou = "您的输入有误!";
    }
    System.out.println(buHuanGou + "\n感谢您的光临,欢迎再次惠顾!");
    }


    }
    }
  • 相关阅读:
    删除List集合中的元素你碰到过这样的陷阱吗?
    从spring框架中的事件驱动模型出发,优化实际应用开发代码
    SpringBoot启动原理及相关流程
    基于SpringBoot实现定时任务的设置(常用:定时清理数据库)
    C#开发中常用的加密解密方法
    http://go.microsoft.com/fwlink/?linkid问题
    移动端开发必须知道的小技巧
    工作中遇到的细节问题总结(二)
    redis分布式锁和消息队列
    join和wait
  • 原文地址:https://www.cnblogs.com/qobin/p/2306888.html
Copyright © 2011-2022 走看看