import java.util.Scanner;

public class SwitchExample {
    public static void main(String[] args) {
        Scanner myScanner = new Scanner(System.in);
        
        int number = 2;
        while (true) {
            //print out the options
            System.out.println("Your number is " + number);
            System.out.println("What would you like to do?");
            System.out.println("1. Change number");
            System.out.println("2. Exit program");
            
            int option = myScanner.nextInt();
            switch(option) {
                case 1: //Change the number
                    
                    boolean decided = false;
                    while (!decided) {
                        //Ask for the new number
                        System.out.println("What do you like to change your number to?");
                        int newnumber = myScanner.nextInt();
                        
                        //print out the options
                        System.out.println("Your old number is " + number + " and your new is " + newnumber);
                        System.out.println("What would you like to do?");
                        System.out.println("1. Pick another number");
                        System.out.println("2. Use the new number");
                        System.out.println("3. Stick with the old one");
                        int option2 = myScanner.nextInt();
                        
                        switch (option2) {
                            case 1: //Pick a new option
                                break;
                                
                            case 2: //Exit and use the new number
                                number = newnumber;
                                
                            case 3: //Exit and use the old number
                                decided = true;
                                break;
                            default:
                                System.out.println("Invalid option");
                                
                        }
                    }
                    break;
                case 2: //Exit the program                   
                    System.out.println("Your final number is " + number);
                    return;
                    
                default:
                    System.out.println("Invalid option");
            }
        }
    }
    
}