So basically in the case 1 of main function, I am trying to store the two values the user input into another class. Then if I go to case 2 immediately, the output will be the sum of the two values that were input earlier. My question is how to change my code such that case 2 and 3 are able to use the values that I have stored in case 1 earlier? Thank you.

Code for main function:

```
import java.util.Scanner;
public class calculatorfinal
{
  public static void main(String args[])
    {
     int number1,number2,choice,sum,product;
     while(true)
             {
              Scanner scan = new Scanner(System.in);
              operations myoperations=new operations();
              System.out.println("\n1. Get numbers");
              System.out.println("\n2. Addition");
              System.out.println("\n3. Multiplication");
              System.out.println("\n4. Exit");
              choice = scan.nextInt();

              switch(choice)
                    { 
                      case 1:
                            System.out.println("enter the two numbers:");
                            number1=scan.nextInt();
                            number2=scan.nextInt();
                            myoperations.getnumbers(number1,number2);
                            break;
                      case 2:
                            myoperations.addnumbers();
                            break;
                      case 3:
                           myoperations.multiplynumbers();
                           break;
                      case 4:
                           System.exit(0);
                           break;
                   }
             }
     }
}

```

Code for another class(the operations) 

```
public class operations
 {
  int a,b;   
  public void addnumbers()
   {
    int sum = a+b;
    System.out.println("ans is "+sum);
   }
  public void multiplynumbers()
   {
    int product = a*b;
    System.out.println("ans is "+product);
   }
    public void getnumbers(int number1,int number2)
   {
    a=number1;
    b=number2;
    System.out.println("the first number is "+number1);
    System.out.println("the second number is "+number2);
   }
 }

```