题解 | 计算商场折扣

计算商场折扣

https://www.nowcoder.com/practice/cf4dcda7bf974f83afe38af4b14946a7

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner console = new Scanner(System.in);
        int price = console.nextInt();
        int cost = 0;

        if(price<100){
            cost = price;
        }else if(price>=100&&price<500){
            cost = (int)(price*0.9);
        }else if(price>=500&&price<2000){
            cost = (int)(price*0.8);
        }else if(price>=2000&&price<5000){
            cost=   (int)(price*0.7);
        }else {
            cost = (int)(price*0.6);
        }
        

        System.out.println(cost);
    }
}

直接分情况计算就行

全部评论

相关推荐

见见123:简历没有啥问题,是这个社会有问题。因为你刚毕业,没有工作经历,现在企业都不要没有工作经历的。社会病了。
点赞 评论 收藏
分享
自学java狠狠赚一...:骗你点star的,港卵公司,记得把star收回去
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务