【发布时间】:2016-11-12 06:55:23
【问题描述】:
我正在尝试将用户输入添加到我的班级中,以便用户可以输入他们的包裹重量,而我的班级会告诉他们要花多少钱。我对 java 很陌生,所以我知道这并不令人惊奇,但这是我目前能做的最好的事情。提前致谢
public class ShippingCosts {
public static void main(String[] args) {
// TODO Auto-generated method stub
int weight = 0;
if (0 < weight && weight <= 1)
System.out.println("The cost to ship the package is $3.50");
if (1 < weight && weight <= 3)
System.out.println("The cost to ship the package is $5.50");
if (3 < weight && weight <= 10)
System.out.println("The cost to ship the package is $9.50");
if (10 < weight && weight <= 20)
System.out.println("The cost to ship the package is $13.50");
if (20 < weight)
System.out.println("The package is too heavy to be shipped");
System.out.println("How heavy is the package?");
}
}
【问题讨论】:
-
发帖前请先搜索 Stack Overflow。
标签: java if-statement int