1. Addition
2. Substraction
3. Multiplication
4. Division
5. Exit
*/
import java.lang.*;
import java.io.*;
class oprations
{
public void InputMsg()
{System.out.println("Enter Two Integer numbers. ");}
public void continueMsg()
{System.out.println("Do you want to Continue. \n1. Yes \n0. No");}
public static void main (String args[]) throws IOException
{
int a , b, choice = -1 ;
do
{
System.out.println("Choose a Opration");
System.out.println("1. Addition \n2. Substraction \n3. Multiplication \n4. Division \n5. Exit \nYour Choice: ");
BufferedReader br = new BufferedReader(new
InputStreamReader(System.in));
oprations e = new oprations();
choice = Integer.parseInt(br.readLine());
int repeate = -1;
do
{
switch(choice)
{
case 1: e.InputMsg();
a = Integer.parseInt(br.readLine());
b = Integer.parseInt(br.readLine());
System.out.println("Addition = "+(a+b));
e.continueMsg();
repeate = Integer.parseInt(br.readLine());
break;
case 2: e.InputMsg();
a = Integer.parseInt(br.readLine());
b = Integer.parseInt(br.readLine());
System.out.println("Substraction = "+(a-b));
e.continueMsg();
repeate = Integer.parseInt(br.readLine());
break;
case 3: e.InputMsg();
a = Integer.parseInt(br.readLine());
b = Integer.parseInt(br.readLine());
System.out.println("Multiplication = "+(a*b));
e.continueMsg();
repeate = Integer.parseInt(br.readLine());
break;
case 4: e.InputMsg();
a = Integer.parseInt(br.readLine());
b = Integer.parseInt(br.readLine());
System.out.println("Division = "+(a/b));
e.continueMsg();
repeate = Integer.parseInt(br.readLine());
break;
case 5: System.out.println("BYE!");
break;
default: System.out.println("Invalid Input.");
}
}while(repeate != 0 && choice != 5);
}while(choice != 5);
}
}
No comments:
Post a Comment