import java.util.*;
public class calculator
{
public static void main(String args[])
{
Scanner p = new Scanner(System.in);
int num1,num2,n;
System.out.println("Enter 1 to calculate sum 2 for subtraction 3 for product 4 for division");
n=p.nextInt();
switch(n)
{
case 1:
System.out.println("Ente two numbers ");
num1=p.nextInt();
num2=p.nextInt();
System.out.println("The sum of two numbers is :"+(num1+num2));
break;
case 2:
System.out.println("Ente two numbers ");
num1=p.nextInt();
num2=p.nextInt();
System.out.println("The subtraction of two numbers is :"+(num1-num2));
break;
case 3:
System.out.println("Ente two numbers ");
num1=p.nextInt();
num2=p.nextInt();
System.out.println("The product of two numbers is :"+(num1*num2));
break;
case 4:
System.out.println("Ente two numbers ");
num1=p.nextInt();
num2=p.nextInt();
System.out.println("The division of two numbers is :"+(num1/num2));
break;
default:
System.out.println("You Enter a wrong number");
}}}
0 comments:
Post a Comment