加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

Java,找不到符号错误?

发布时间:2020-12-15 04:32:04 所属栏目:Java 来源:网络整理
导读:我试图计算单价17的总价格和物品数量20. public class hw1_task3 { public static void main(String[] args) { int total = units * price; int units = 20; int price = 17; System.out.printf("The total is: %d",total); } } 该计划有什么问题?我一直收
我试图计算单价17的总价格和物品数量20.

public class hw1_task3 {
    public static void main(String[] args) {
        int total = units * price;
        int units = 20;
        int price =  17;
        System.out.printf("The total is: %d",total);
    }    
}

该计划有什么问题?我一直收到一个关于无法找到符号的错误.我是java的新手,非常感谢任何帮助.

解决方法

您需要将单位和价格移动到总数之上,如下所示:

int price =  17;
int units = 20;
int total = units * price;

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读