// Shipping and Taxes // Load Java's I/O facilities: import java.io.*; public class p2Charge { public static void main(String[] args) throws IOException { // Create object $in$ that allows you to prompt user for input: BufferedReader in = new BufferedReader (new InputStreamReader(System.in)); // Variables: double weight; // user-input weight to ship int code; // destination code for the package double charge; // the charge for the user based on $weight$ and $code$ // Get shipping info: System.out.print("Enter the weight to ship: "); weight = Double.valueOf(in.readLine()).doubleValue(); System.out.print("Enter the destination code: "); code = Integer.parseInt(in.readLine()); // Determine $charge$ based on $weight$: charge = 0; if (weight <= 5) charge = 12; else if (weight < 10) charge = 18; else if (weight >= 10) charge = 20 + 1.50 * (weight - 10); else { System.out.println("Do not enter such a weird weight!"); System.exit(0); } // Modify $charge$ with tax based on $code$: if (code==1) charge = charge * 1.08; System.out.println("The shipping charge is "+charge); } }