import java.util.Scanner; public class Case { public static void main(String[] args) { double taxRate = 0.15; // pet tax rate String name; // what they buy double price; // show user the options and get their choice System.out.println("1. Dog"); System.out.println("2. Cat"); System.out.println("3. Llama"); System.out.println("4. Robo-Mecha Horse"); int choice = promptInt("What is your choice?"); // depending on choice, set variables switch(choice) { case 1: name = "Dog"; price = 59.99; break; // java syntax needs this // otherwise, code will continue to next case! case 2: name = "Cat"; price = 20.00; break; case 3: name ="Llama"; price = 229.99; taxRate = 0.17; // exotic tax break; case 4: name = "Robo-Mecha Horse"; price = 59699.57; taxRate = 0.03; // preferential tax for robot overlords break; default: // what to do if they chose none of the above numbers name = "No Sale"; price = 0; break; } // tell them the final bill: System.out.println("Your Purchase:"); System.out.println(name); double tax = price * taxRate; double total = price + tax; System.out.println("$" + total); } // end main // utility for reading in integer input public static int promptInt(String promptText) { System.out.print(promptText + " "); Scanner scan = new Scanner(System.in); int response = scan.nextInt(); return response; } }