import java.io.*;
class ArithematicsWithSwitch
{
public static void main(String args[])
{
int num1,num2,res,i;
DataInputStream r = new DataInputStream(System.in);
try
{
System.out.println("Enter the Numbers");
System.out.println("Enter the Num 1 = ");
num1 = Integer.parseInt(r.readLine());
System.out.println("Enter the Num 2 = ");
num2 = Integer.parseInt(r.readLine());
System.out.println("Select a option:\n1.Addition\n2.Subtraction\n3.Multiplication\n4.Division\n5.Modolus");
i = Integer.parseInt(r.readLine());
switch(i)
{
case 1:
res = num1+num2;
System.out.println("Sum of Num1 and Num2 is = "+res);
break;
case 2:
res = num1-num2;
System.out.println("Subtraction of Num1 and Num2 is = "+res);
break;
case 3:
res = num1*num2;
System.out.println("Multiplication of Num1 and Num2 is = "+res);
break;
case 4:
res = num1/num2;
System.out.println("Division of Num1 and Num2 is = "+res);
break;
case 5:
res = num1%num2;
System.out.println("Modolus of Num1 and Num2 is = "+res);
break;
default:
System.out.println("Invalide Number enter");
break;
}
}
catch(Exception e)
{
System.out.println("error is occur in "+e);
}
}
}
class ArithematicsWithSwitch
{
public static void main(String args[])
{
int num1,num2,res,i;
DataInputStream r = new DataInputStream(System.in);
try
{
System.out.println("Enter the Numbers");
System.out.println("Enter the Num 1 = ");
num1 = Integer.parseInt(r.readLine());
System.out.println("Enter the Num 2 = ");
num2 = Integer.parseInt(r.readLine());
System.out.println("Select a option:\n1.Addition\n2.Subtraction\n3.Multiplication\n4.Division\n5.Modolus");
i = Integer.parseInt(r.readLine());
switch(i)
{
case 1:
res = num1+num2;
System.out.println("Sum of Num1 and Num2 is = "+res);
break;
case 2:
res = num1-num2;
System.out.println("Subtraction of Num1 and Num2 is = "+res);
break;
case 3:
res = num1*num2;
System.out.println("Multiplication of Num1 and Num2 is = "+res);
break;
case 4:
res = num1/num2;
System.out.println("Division of Num1 and Num2 is = "+res);
break;
case 5:
res = num1%num2;
System.out.println("Modolus of Num1 and Num2 is = "+res);
break;
default:
System.out.println("Invalide Number enter");
break;
}
}
catch(Exception e)
{
System.out.println("error is occur in "+e);
}
}
}
No comments:
Post a Comment