-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStaticWay.java
More file actions
37 lines (32 loc) · 770 Bytes
/
StaticWay.java
File metadata and controls
37 lines (32 loc) · 770 Bytes
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
32
33
34
35
36
37
package Reflection;
import java.util.Scanner;
public class StaticWay {
public static void main(String[] args) {
int a = 100;
int b = 200;
Calculator calc = new Calculator();
System.out.println("add");
System.out.println("subtract");
System.out.println("multiply");
System.out.println("divide");
System.out.println("Type Operation Name");
Scanner scanner = new Scanner(System.in);
String operation = scanner.next();
int result = 0;
switch (operation) {
case "add":
result = calc.add(a, b);
break;
case "subtract":
result = calc.subtract(a, b);
break;
case "multiply":
result = calc.multiply(a, b);
break;
case "divide":
result = calc.divide(a, b);
break;
}
System.out.println("Result is " + result);
}
}