Showing
3 changed files
with
3 additions
and
90 deletions
dcloud/calculator.java
deleted
100644 → 0
1 | -import java.util.Scanner; | ||
2 | - | ||
3 | -class calculator{ | ||
4 | - public static void main(String[] args) { | ||
5 | - | ||
6 | - Scanner scn = new Scanner(System.in); | ||
7 | - | ||
8 | - System.out.print("Input first args: "); | ||
9 | - | ||
10 | - float num1 = scn.nextFloat(); | ||
11 | - | ||
12 | - System.out.print("Input second args: "); | ||
13 | - float num2 = scn.nextFloat(); | ||
14 | - | ||
15 | - System.out.print("Input Operator(+,-,/,*): "); | ||
16 | - | ||
17 | - String oper = scn.next(); | ||
18 | - | ||
19 | - float result = 0.0f; | ||
20 | - | ||
21 | - switch (oper) { | ||
22 | - case "+": | ||
23 | - result = num1 + num2; | ||
24 | - break; | ||
25 | - | ||
26 | - case "-": | ||
27 | - result = num1 - num2; | ||
28 | - break; | ||
29 | - | ||
30 | - case "/": | ||
31 | - result = num1 / num2; | ||
32 | - break; | ||
33 | - | ||
34 | - case "*": | ||
35 | - result = num1 * num2; | ||
36 | - break; | ||
37 | - | ||
38 | - default: | ||
39 | - break; | ||
40 | - } | ||
41 | - | ||
42 | - System.out.println("Result is " + result); | ||
43 | - scn.close(); | ||
44 | - } | ||
45 | -} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
dcloud/media/calculator.java
deleted
100644 → 0
1 | -import java.util.Scanner; | ||
2 | - | ||
3 | -class calculator{ | ||
4 | - public static void main(String[] args) { | ||
5 | - | ||
6 | - Scanner scn = new Scanner(System.in); | ||
7 | - | ||
8 | - System.out.print("Input first args: "); | ||
9 | - | ||
10 | - float num1 = scn.nextFloat(); | ||
11 | - | ||
12 | - System.out.print("Input second args: "); | ||
13 | - float num2 = scn.nextFloat(); | ||
14 | - | ||
15 | - System.out.print("Input Operator(+,-,/,*): "); | ||
16 | - | ||
17 | - String oper = scn.next(); | ||
18 | - | ||
19 | - float result = 0.0f; | ||
20 | - | ||
21 | - switch (oper) { | ||
22 | - case "+": | ||
23 | - result = num1 + num2; | ||
24 | - break; | ||
25 | - | ||
26 | - case "-": | ||
27 | - result = num1 - num2; | ||
28 | - break; | ||
29 | - | ||
30 | - case "/": | ||
31 | - result = num1 / num2; | ||
32 | - break; | ||
33 | - | ||
34 | - case "*": | ||
35 | - result = num1 * num2; | ||
36 | - break; | ||
37 | - | ||
38 | - default: | ||
39 | - break; | ||
40 | - } | ||
41 | - | ||
42 | - System.out.println("Result is " + result); | ||
43 | - scn.close(); | ||
44 | - } | ||
45 | -} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment