import java.io.*; public class SwitchAssign{ public static void main(String []args) throws IOException{ String planet = ""; int weight; double tempweight; boolean error; // indicates whether the seletion is correct int selection; // indicates the selection BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); System.out.println("Input your weight in Earth pounds: "); weight = Integer.parseInt(in.readLine()); tempweight = (double)weight; System.out.println(); System.out.println("Enter a number to choose a planet:"); System.out.println("1) Mercury"); System.out.println("2) Venus"); System.out.println("3) Mars"); System.out.println("4) Saturn"); System.out.println("5) Jupiter"); System.out.println("6) Neptune"); System.out.println("7) Uranus"); System.out.println("8) Pluto"); selection = Integer.parseInt(in.readLine()); switch (selection){ case 1 : tempweight *=.38; planet="Mercury"; error = false; break; case 2 : tempweight *=.78; planet = "Venus"; error = false; break; case 3 : tempweight *=.39; planet="Mars"; error = false; break; case 4 : tempweight *=1.17; planet="Saturn"; error = false; break; case 5 : tempweight *=2.65; planet="Jupiter"; error = false; break; case 6 : tempweight *=1.23; planet="Neptune"; error = false; break; case 7 : tempweight *=1.05; planet="Uranus"; error = false; break; case 8 : tempweight *=.05; planet="Pluto"; error = false; break; default : System.out.println("You did not select" + " a planet from the list."); error = true; } // the switch statement computes the converted weight // based upon the planet specified if(!error) { weight = (int)Math.round(tempweight); System.out.println("\nYou weigh " + weight + " pounds on " + planet + "."); } // prints out the final result // if selection is correct } }