-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQ2.4.txt
31 lines (29 loc) · 1.09 KB
/
Q2.4.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
public class TwoNumbers {
public static void main(String args[]){
if(args.length==0){
System.out.println("No arguments are passed");
}
else
{
int a = Integer.parseInt(args[0]);
int b = Integer.parseInt(args[1]);
char c = args[2].charAt(0);
switch (c){
case '+':
System.out.println("Addition of "+ a +" and "+b+" : "+(a+b));
break;
case '-':
System.out.println("Subtraction of "+ a +" and "+b+" : "+(a+b));
break;
case '*':
System.out.println("Multification of "+ a +" and "+b+" : "+(a+b));
break;
case '/':
System.out.println("Division of "+ a +" and "+b+" : "+(a+b));
break;
default:
System.out.println("Please enter + , - , / , * operator only");
}
}
}
}