-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcalculator.java
More file actions
47 lines (37 loc) · 1.25 KB
/
calculator.java
File metadata and controls
47 lines (37 loc) · 1.25 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
38
39
40
41
42
43
44
45
46
47
import java.util.*;
public class calculator {
public static void main(String[] args) {
// start:
Scanner sc = new Scanner(System.in);
System.out.println("\n\n\nthis is the calculator \n ~~~~~~~~~~~~~~~~\n");
System.out.println("enter your first digit ");
float a = sc.nextFloat();
System.out.println("enter your second digit ");
float b = sc.nextFloat();
System.out.println(
"\n\nenter A for addition \n enter S for subtrction \n enter M for multiplication \n enter D for division ");
String sw = sc.next();
float result;
switch (sw) {
case "D":
result = a / b;
System.out.println("the division of digits is " + result);
// goto start;
break;
case "M":
result = a * b;
System.out.println("the multiplication of digits is " + result);
break;
case "S":
result = a - b;
System.out.println("the diff of digits is " + result);
break;
case "A":
result = a + b;
System.out.println("the sum of digits is " + result);
break;
default:
break;
}
}
}