c语言switch购物折扣,编写程序,输入购物款数,计算并输出优惠价。(要求用switch语句编写)…

满意答案

f6ebf20d3e684be627ce39d84a92df83.png

易兮_

2014.12.07

f6ebf20d3e684be627ce39d84a92df83.png

采纳率:46% 等级:18

已帮助:14469人

import java.util.*;

public class hu {

public static void main(String[] args) {

System.out.println(“请输入消费金额:”);

Scanner ji = new Scanner(System.in);

double money = ji.nextDouble();

int xuanze;

xuanze = (int) money / 1000;

if (xuanze < 1) {

System.out.println(“你的消费金额是:” + money);

return;

}

switch (xuanze) {

case 1:

double hou;

hou = money * 0.95;

System.out.println(“你的消费金额是:” + money);

System.out.println(“打折后是:” + hou);

break;

case 2:

hou = money * 0.9;

System.out.println(“你的消费金额是:” + money);

System.out.println(“打折后是:” + hou);

break;

case 3:

case 4:

hou = money * 0.85;

System.out.println(“你的消费金额是:” + money);

System.out.println(“打折后是:” + hou);

break;

case 5:

hou = money * 0.8;

System.out.println(“你的消费金额是:” + money);

System.out.println(“打折后是:” + hou);

break;

default:

hou = money * 0.8;

System.out.println(“你的消费金额是:” + money);

System.out.println(“打折后是:” + hou);

}

}

}

10分享举报

原文链接:https://blog.csdn.net/weixin_34626306/article/details/117123609?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522165277499316782395393704%2522%252C%2522scm%2522%253A%252220140713.130102334.pc%255Fblog.%2522%257D&request_id=165277499316782395393704&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~blog~first_rank_ecpm_v1~times_rank-28-117123609-null-null.nonecase&utm_term=%E4%BC%98%E6%83%A0

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发
头像
文明发言,共建和谐米科社区
提交
头像

昵称

取消
昵称表情图片