answersLogoWhite

0


Best Answer

import java.io.*;


public class calculator{
public static void main(String[] args) throws Exception{
int x, y;
BufferedReader b = new BufferedReader(new InputStreamReader(System.in)) ;
System.out.println("Enter two numbers for operation:");


x = Integer.parseInt(b.readLine());
y = Integer.parseInt(b.readLine());
System.out.println("1. Add");
System.out.println("2. Subtract");
System.out.println("3. Multiply");
System.out.println("4. Divide");
System.out.println("enter your choice:");
int a= Integer.parseInt(b.readLine());
switch (a){
case 1:
System.out.println("Enter the number one=" + (x+y));
break;
case 2:
System.out.println("Enter the number two=" + (x-y));
break;
case 3:
System.out.println("Enetr the number three="+ (x*y));
break;
case 4:
System.out.println("Enter the number four="+ (x/y));
break;
default:
System.out.println("Invalid Entry!");
}






}
}

User Avatar

Wiki User

15y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Coding of calculator programme using switch case in java?
Write your answer...
Submit
Still have questions?
magnify glass
imp