回答編集履歴

5

改正

2017/01/11 18:16

投稿

退会済みユーザー
test CHANGED
@@ -8,76 +8,78 @@
8
8
 
9
9
  public class MPO {
10
10
 
11
- public static void main(String[] args) {
11
+ public static void main(String[] args) {
12
12
 
13
13
 
14
14
 
15
- Scanner sc = new Scanner(System.in);
15
+ Scanner sc = new Scanner(System.in);
16
16
 
17
- int a, b;
17
+ int a=0, b=0;
18
18
 
19
- System.out.print("数1:");
19
+
20
20
 
21
- a = sc.nextInt();
21
+ while (a >= 10 || a<1) {
22
22
 
23
- while (a >= 10 || a<1) {
23
+ System.out.print("数1[10未満1以上]:");
24
24
 
25
- System.out.print("数1[10未満1以上]:");
25
+ String a1 = sc.next();
26
+
27
+ try{
28
+
29
+ a=Integer.parseInt(a1);
30
+
31
+ }catch(Exception e){}
32
+
33
+ }
26
34
 
27
35
 
28
36
 
29
- a = sc.nextInt();
37
+ while (b >= 10 || b<1) {
30
38
 
31
- }
39
+ System.out.print("数2[10未満1以上]:");
32
40
 
33
- System.out.print("数2:");
41
+ String b1 = sc.next();
42
+
43
+ try{
44
+
45
+ b=Integer.parseInt(b1);
46
+
47
+ }catch(Exception e){}
48
+
49
+ }
34
50
 
35
51
 
36
52
 
37
- b = sc.nextInt();
53
+ while (true) {
38
54
 
39
- while (b >= 10 || b<1) {
55
+ System.out.print("算術演算子:");
40
56
 
41
- System.out.print("数2[10未満1以上]:");
42
-
43
- b = sc.nextInt();
57
+ String p = sc.next();
44
-
45
- }
46
58
 
47
59
 
48
60
 
49
- while (true) {
50
-
51
- System.out.print("算術演算子:");
61
+ if (p.equals("+")) {
52
-
53
- String p = sc.next();
54
62
 
55
63
 
56
64
 
65
+ System.out.println(a + b);
66
+
67
+ break;
68
+
57
- if (p.equals("+")) {
69
+ } else if (p.equals("-")) {
70
+
71
+ System.out.println(a - b);
72
+
73
+ break;
74
+
75
+ }
58
76
 
59
77
 
60
78
 
61
- System.out.println(a + b);
79
+ }
62
80
 
63
- break;
64
-
65
- } else if (p.equals("-")) {
66
-
67
- System.out.println(a - b);
68
-
69
- break;
70
-
71
- }
81
+ }
72
-
73
-
74
-
75
- }
76
-
77
- }
78
82
 
79
83
  }
80
84
 
81
-
82
-
83
85
  ```

4

改正

2017/01/11 18:16

投稿

退会済みユーザー
test CHANGED
File without changes

3

改正

2017/01/11 18:16

投稿

退会済みユーザー
test CHANGED
@@ -20,7 +20,7 @@
20
20
 
21
21
  a = sc.nextInt();
22
22
 
23
- while (a >= 10 || a<0) {
23
+ while (a >= 10 || a<1) {
24
24
 
25
25
  System.out.print("数1[10未満1以上]:");
26
26
 
@@ -36,7 +36,7 @@
36
36
 
37
37
  b = sc.nextInt();
38
38
 
39
- while (b >= 10 || b<0) {
39
+ while (b >= 10 || b<1) {
40
40
 
41
41
  System.out.print("数2[10未満1以上]:");
42
42
 

2

改正

2017/01/11 18:10

投稿

退会済みユーザー
test CHANGED
@@ -22,7 +22,7 @@
22
22
 
23
23
  while (a >= 10 || a<0) {
24
24
 
25
- System.out.print("数1[10以下1以上]:");
25
+ System.out.print("数1[10未満1以上]:");
26
26
 
27
27
 
28
28
 
@@ -38,7 +38,7 @@
38
38
 
39
39
  while (b >= 10 || b<0) {
40
40
 
41
- System.out.print("数2[10以下1以上]:");
41
+ System.out.print("数2[10未満1以上]:");
42
42
 
43
43
  b = sc.nextInt();
44
44
 

1

改正

2017/01/11 18:05

投稿

退会済みユーザー
test CHANGED
@@ -20,9 +20,9 @@
20
20
 
21
21
  a = sc.nextInt();
22
22
 
23
- while (a > 10) {
23
+ while (a >= 10 || a<0) {
24
24
 
25
- System.out.print("数1[10以下]:");
25
+ System.out.print("数1[10以下1以上]:");
26
26
 
27
27
 
28
28
 
@@ -36,9 +36,9 @@
36
36
 
37
37
  b = sc.nextInt();
38
38
 
39
- while (b > 10) {
39
+ while (b >= 10 || b<0) {
40
40
 
41
- System.out.print("数2[10以下]:");
41
+ System.out.print("数2[10以下1以上]:");
42
42
 
43
43
  b = sc.nextInt();
44
44