import java.util.*; // compute the cost of shipping a package based on its weight public class Prog3_18 { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter the weight of the package in pounds: "); double weight = in.nextDouble(); double cost = -1.0; // default cost in case weight exceeds limit if(weight<=0) System.out.println("Error, package cannot 0 or negative pounds"); else { if(weight <= 1) cost = weight * 3.5; else if(weight <= 3) cost = weight * 5.5; else if(weight <= 10) cost = weight * 8.5; else if(weight <= 20) cost = weight * 10.5; if(cost >= 0) System.out.printf("%s $%6.2f", "The cost to ship your package of " + weight + " pounds is ", cost); else System.out.println("Cannot ship a package that weighs " + weight + " pounds, try Fedex"); } } }