質問編集履歴
1
抜けていた部分を加えました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -14,65 +14,73 @@
|
|
14
14
|
|
15
15
|
```java
|
16
16
|
|
17
|
+
import java.util.Scanner;
|
18
|
+
|
17
|
-
public
|
19
|
+
public class calcu01
|
18
20
|
|
19
21
|
{
|
20
22
|
|
21
|
-
|
23
|
+
public static void main(String[] args)
|
22
24
|
|
23
|
-
|
25
|
+
{
|
24
26
|
|
25
|
-
|
27
|
+
Scanner sc = new Scanner(System.in);
|
26
28
|
|
27
|
-
|
29
|
+
while(true){
|
28
30
|
|
29
|
-
S
|
31
|
+
System.out.print(">> ");
|
30
32
|
|
31
|
-
tr
|
33
|
+
if (!sc.hasNextLine()) break;
|
32
34
|
|
33
|
-
|
35
|
+
String line = sc.nextLine();
|
34
36
|
|
35
|
-
S
|
37
|
+
Scanner sc2 = new Scanner(line);
|
36
38
|
|
37
|
-
|
39
|
+
try{
|
38
40
|
|
39
|
-
double
|
41
|
+
double x = sc2.nextDouble();
|
40
42
|
|
41
|
-
s
|
43
|
+
String op = sc2.next();
|
42
44
|
|
43
|
-
|
45
|
+
double y = sc2.nextDouble();
|
44
46
|
|
45
|
-
|
47
|
+
double z = 0;
|
46
48
|
|
47
|
-
c
|
49
|
+
switch(op){
|
48
50
|
|
49
|
-
case "
|
51
|
+
case "q": z = x + y; break;
|
50
52
|
|
51
|
-
case "
|
53
|
+
case "w": z = x - y; break;
|
52
54
|
|
53
|
-
|
55
|
+
case "e": z = x * y; break;
|
54
56
|
|
55
|
-
|
57
|
+
case "r": z = x / y; break;
|
56
58
|
|
59
|
+
case "z":
|
60
|
+
|
61
|
+
put("終了します");
|
62
|
+
|
63
|
+
System.exit(0);
|
64
|
+
|
57
|
-
break;
|
65
|
+
break;
|
66
|
+
|
67
|
+
}
|
68
|
+
|
69
|
+
System.out.println(z);
|
58
70
|
|
59
71
|
}
|
60
72
|
|
73
|
+
catch(Exception e){
|
74
|
+
|
61
|
-
System.out.println(
|
75
|
+
System.out.println(" Error");
|
76
|
+
|
77
|
+
}
|
78
|
+
|
79
|
+
sc2.close();
|
62
80
|
|
63
81
|
}
|
64
82
|
|
65
|
-
catch(Exception e){
|
66
|
-
|
67
|
-
System.out.println(" Error");
|
68
|
-
|
69
|
-
}
|
70
|
-
|
71
|
-
sc2.close();
|
72
|
-
|
73
|
-
}
|
74
|
-
|
75
|
-
sc.close();
|
83
|
+
sc.close();
|
76
84
|
|
77
85
|
}
|
78
86
|
|