2.4编程题

2.4编程题

public class DisCountDemo {
     public void jiaGe(float totalPrice){
	        if(totalPrice>200){
	            float zh=totalPrice*0.85f;
	            System.out.println("折后商品总价为:"+zh);}
	        if(totalPrice>100&&totalPrice<199){
	            float zh = totalPrice*0.95f;
	             System.out.println("折后商品总价为:"+zh);}
	        
	            
	    }
    //根据商品总价输出折后总价

	public static void main(String[] args) {
		//定义对象
		DiscountDemo sc=new DiscountDemo();
		sc.jiaGe(150.0f);
		
		//定义商品总价存放到变量中
		

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

  代码在eclipse上运行可以,在答题区运行 显示错误

正在回答 回答被采纳积分+1

登陆购买课程后可参与讨论,去登陆

2回答
喜欢做梦的鱼 2018-03-28 19:56:40

http://img1.sycdn.imooc.com//climg/5abb82de000188b606330383.jpg同学,如果你的代码没有贴错,不可能可以正常运行,类名大小写都不一致,请仔细再检查一下!

提问者 慕婉清3746980 2018-03-28 19:48:54
运行失败
DisCountDemo.java:16: error: cannot find symbol
		DiscountDemo sc=new DiscountDemo();
		^
  symbol:   class DiscountDemo
  location: class DisCountDemo
DisCountDemo.java:16: error: cannot find symbol
		DiscountDemo sc=new DiscountDemo();
		                    ^
  symbol:   class DiscountDemo
  location: class DisCountDemo
2 errors


  • 注意大小写 DisCountDemo 是你声明的 DiscountDemo 计算机找不到,改为 DisCountDemo 初学,尽量让名字简单点
    2018-03-31 23:53:38
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师