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"); } }
|