Aim:- Write a program to enter two numbers and perform
mathematical operations on them.
JAVA Code :-
import
java.lang.*;
class
cal
{
public static void main(String args[])
{
int a,b,ans;
a= Integer.parseInt(args[0]);
b= Integer.parseInt(args[1]);
switch(args[2])
{
case "+":
ans=a+b;
System.out.println("Add=
"+ans);
break;
case "-":
ans=a-b;
System.out.println("Sub=
"+ans);
break;
case "*":
ans=a*b;
System.out.println("Mul=
"+ans);
break;
case "/":
ans=a/b;
System.out.println("Div=
"+ans);
break;
}
}
}
Output:-
No comments:
Post a Comment