-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCalculator.java
More file actions
37 lines (25 loc) · 1.04 KB
/
Copy pathCalculator.java
File metadata and controls
37 lines (25 loc) · 1.04 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
30
31
32
33
34
35
36
37
import java.util.*;
public class Calculator {
public static void main(String[] args) {
System.out.println("\t \t Welcome to our Calculator\n");
Scanner sc = new Scanner(System.in);
System.out.print("Enter a number: ");
double num1 = sc.nextDouble();
System.out.print("Enter a number: ");
double num2 = sc.nextDouble();
System.out.println("\t \tSelect an Option \nAddition (1) \nSubtraction (2) \nMultiplication(3) \nDivision (4)\n");
int option = sc.nextInt();
switch (option) {
case 1: { System.out.println("Addition =" + (num1 + num2));}
break;
case 2: {System.out.println("Subtraction = " + (num1 - num2));}
break;
case 3: { System.out.println("Multiplcation = " + (num1 * num2));}
break;
case 4: {System.out.println("Division = " + (num1 / num2));}
break;
default:
{System.out.println("Invalid option");}
}
}
}