-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCalculator
More file actions
29 lines (29 loc) · 1.02 KB
/
Calculator
File metadata and controls
29 lines (29 loc) · 1.02 KB
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
// Press Shift twice to open the Search Everywhere dialog and type `show whitespaces`,
// then press Enter. You can now see whitespace characters in your code.
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter the value1: ");
int a = sc.nextInt();
System.out.print("Enter the value2: ");
int b = sc.nextInt();
System.out.println("1. ADD\n2. SUBRACT \n3. MULTIPLY \n4. DIVIDE");
System.out.print("Enter the Operation number: ");
int n = sc.nextInt();
switch(n){
case 1:
System.out.print("Result = " + (a+b));
break;
case 2:
System.out.print("Result = " + (a-b));
break;
case 3:
System.out.print("Result = " + (a*b));
break;
case 4:
System.out.print("Result = " + (a/b));
break;
}
}
}