public class Getnumbers {
	private int num1;
	private int num2;
	public int getNum1() {
		return num1;
	}
	public void setNum1(int num1) {

		this.num1 = num1;
	}
	public int getNum2() {
		return num2;
	}
	public void setNum2(int num2) {

	this.num2 = num2;
	}

}
import java.util.Scanner;
public class Case {

	public static  void display1 ()
	{
		System.out.println("Enter First Number ");
	}
	
	public static  void display2 ()
	{
		System.out.println("Enter Second Number ");
	}
		
	
	
	public static void main(String[] args) {
		Getnumbers  num1 = new Getnumbers();
		Getnumbers  num2 = new Getnumbers();
		
		Scanner input = new Scanner(System.in);
		
		

		int result = 0 ;
		int op ;
		char operation = '+';
		boolean x=true;
		while (x==true)
		{	
		System.out.println("=============================================");
		System.out.println("|            MENU SELECTION DEMO            |");		
		System.out.println("|===========================================|");		 
		System.out.println("| Option :                                  |");
		System.out.println("|         0: Exit                           |");
		System.out.println("|         1: Add                            |");
		System.out.println("|         2: Sub                            |");
		System.out.println("|         3: Mult                           |");
		System.out.println("|         4: Div                            |");
		System.out.println("=============================================");
			op =input.nextInt();
			
		
			switch(op)
			{
				case (0):
					System.out.println("EXIT...");
					System.exit(0);	
				case (1):
					operation ='+';
				display1();
				num1.setNum1(input.nextInt());
				display2();	
				num2.setNum2(input.nextInt());
				result = num1.getNum1()+ num2.getNum2() ;	
				break;
				
				case (2):
					operation ='-';
				display1();
				num1.setNum1(input.nextInt());
				display2();	
				num2.setNum2(input.nextInt());
				result = num1.getNum1()- num2.getNum2() ;	
				break;
			
				case (3):
					operation = '*';
				display1();
				num1.setNum1(input.nextInt());
				display2();	
				num2.setNum2(input.nextInt());	
				result = num1.getNum1()* num2.getNum2() ;	
					break;
				
				case (4):
					operation = '/';
				display1();
				num1.setNum1(input.nextInt());
				display2();	
				num2.setNum2(input.nextInt());
				result =  num1.getNum1()/num2.getNum2() ;	
			
			}
		
			System.out.println(" operation is :\"" +operation+"\"\tthe Result = " + result);
		}

	}

}

You should have made this a code snippet. Nevertheless it is very simple example, very useful only for beginners.

thx very much
its good for beginners

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.