答案家

 找回密码
 立即注册
查看: 1008|回复: 0

Java语言程序设计基础篇_第十版_梁勇_3.18运输成本源码答案

[复制链接]

1万

主题

1万

帖子

80万

积分

校长

Rank: 9Rank: 9Rank: 9

积分
809852
发表于 2016-12-24 15:40:47 | 显示全部楼层 |阅读模式
Java语言程序设计基础篇_第十版_梁勇_3.18运输成本源码答案
package nameyu;import java.util.Scanner;public class Test {
    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        Scanner input = new Scanner(System.in);  
        System.out.print("Enter the weight of the package:");  
        int weight = input.nextInt();  
        if (weight > 0 && weight <= 1)  
            System.out.println("The cost is 3.5");  
        else if (weight > 1 && weight <= 3)  
            System.out.println("The cost is 5.5");  
        else if (weight > 3 && weight <= 10)  
            System.out.println("The cost is 8.5");  
        else if (weight > 10 && weight <= 20)  
            System.out.println("The cost is 10.5");  
        else  
            System.out.println("The package cannot be shipped");
    }
    }   

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

CopyRight(c)2016 www.daanjia.com All Rights Reserved. 本站部份资源由网友发布上传提供,如果侵犯了您的版权,请来信告知,我们将在5个工作日内处理。
快速回复 返回顶部 返回列表