练习打卡,力求简洁

来源:2-4 编程练习

麻辣螺丝粉

2020-07-29 17:07:45

public class DisCountDemo {

    //根据商品总价输出折后总价

    public float discountedPrice(float a){

        float discountedPrice;

        if(a>=200)

            discountedPrice=a*0.85f;

        else if(a>=100)

            discountedPrice=a*0.95f;

        else

            discountedPrice=a;

        return discountedPrice;

    }


public static void main(String[] args) {

//定义对象

DisCountDemo disc=new DisCountDemo();

//定义商品总价存放到变量中

float price=150f;

//调用方法,输出折后商品总价

System.out.println("折后商品总价为:"+disc.discountedPrice(price));

}

}


写回答

1回答

好帮手慕小脸

2020-07-29

已完成练习,棒棒哒!继续加油!

如果我的回答解决了你的疑惑,请采纳,祝学习愉快~

0

0 学习 · 16556 问题

查看课程