質問編集履歴

1

申し訳ございません。Code機能を使用してコードを貼り付けました

2020/01/11 06:08

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -6,37 +6,43 @@
6
6
 
7
7
  以下が私が作成した内容です。
8
8
 
9
+
10
+
9
- ーーーーーーーーーーーーーーーーーーーーーーーーーーー
11
+ ```ここに言語を入力
10
12
 
11
13
  public class test_nyuryoku {
12
14
 
13
- public static void main(String[] args) throws IOException {
15
+ public static void main(String[] args) throws IOException {
16
+
17
+  
18
+
19
+ BufferedReader Write = new BufferedReader(new InputStreamReader(System.in));
20
+
21
+ String STR = Write.readLine();
22
+
23
+ int NUM = Integer.parseInt(STR);
14
24
 
15
25
 
16
26
 
17
- BufferedReader Write = new BufferedReader(new InputStreamReader(System.in));
27
+ if (NUM >= 0) {
18
28
 
19
- String STR = Write.readLine();
29
+ System.out.println("0以上が入力されました");
20
30
 
31
+ } else {
32
+
21
- int NUM = Integer.parseInt(STR);
33
+ System.out.println("マイナスの値が入力されました。");
34
+
35
+ }
36
+
37
+ }
38
+
39
+ }
22
40
 
23
41
 
24
42
 
25
- if (NUM >= 0) {
43
+ ```
26
44
 
27
- System.out.println("0以上が入力されました");
28
45
 
29
- } else {
30
-
31
- System.out.println("マイナスの値が入力されました。");
32
-
33
- }
34
-
35
- }
36
-
37
- }
38
-
39
- ーーーーーーーーーーーーーーーーーーーーーーーーーーー
40
46
 
41
47
 
42
48
 
@@ -50,7 +56,7 @@
50
56
 
51
57
  ◆作成したコード
52
58
 
53
- ーーーーーーーーーーーーーーーーーーーーーーーーーーー
59
+ ```ここに言語を入力
54
60
 
55
61
  import java.io.BufferedReader;
56
62
 
@@ -70,45 +76,39 @@
70
76
 
71
77
  */
72
78
 
79
+ public static int Int_HENKAN(String str) {
73
80
 
81
+ BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
74
82
 
83
+ int NUM;
84
+
75
- public static int Int_HENKAN(String str) {
85
+ System.out.print("数字を入力してください。>");
76
86
 
77
87
 
78
88
 
79
- BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
89
+ try {
80
90
 
81
- int NUM;
91
+ str = br.readLine();
82
92
 
93
+ NUM = Integer.parseInt(str);
94
+
95
+ } catch (IOException e) {
96
+
97
+ // TODO 自動生成された catch ブロック
98
+
83
- System.out.print("数字を入力してください。>");
99
+ e.printStackTrace();
100
+
101
+ return -1;
102
+
103
+ }
104
+
105
+ return NUM;
106
+
107
+ }
84
108
 
85
109
 
86
110
 
87
- try {
88
-
89
- str = br.readLine();
90
-
91
- NUM = Integer.parseInt(str);
92
-
93
- } catch (IOException e) {
94
-
95
- // TODO 自動生成された catch ブロック
96
-
97
- e.printStackTrace();
98
-
99
- return -1;
100
-
101
- }
102
-
103
- return NUM;
104
-
105
- }
106
-
107
-
108
-
109
- public static void main(String[] args) throws IOException {
111
+ public static void main(String[] args) throws IOException {
110
-
111
-
112
112
 
113
113
  // BufferedReader Write = new BufferedReader(new InputStreamReader(System.in));
114
114
 
@@ -118,27 +118,27 @@
118
118
 
119
119
 
120
120
 
121
- Int_HENKAN(NUM);
121
+ Int_HENKAN(NUM);
122
122
 
123
+
123
124
 
125
+ if (NUM >= 0) {
124
126
 
125
- if (NUM >= 0) {
127
+ System.out.println("0以上が入力されました");
126
128
 
127
- System.out.println("0以上が入力されました");
129
+ } else {
128
130
 
129
- } else {
131
+ System.out.println("マイナスの値が入力されました。");
130
132
 
131
- System.out.println("マイナスの値が入力されました。");
133
+ }
132
134
 
133
- }
135
+ }
134
-
135
-
136
-
137
- }
138
136
 
139
137
  }
140
138
 
141
- ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーー
139
+ ```
140
+
141
+
142
142
 
143
143
  Int_HENKAN(NUM)で入力した内容を代入すると認識しておりましたがどうにもうまくいきません。
144
144