質問編集履歴

2

ソースコードの修正

2018/05/11 13:49

投稿

Tazusa
Tazusa

スコア41

test CHANGED
File without changes
test CHANGED
@@ -131,3 +131,117 @@
131
131
 
132
132
 
133
133
  ```
134
+
135
+ 変更後
136
+
137
+ ```
138
+
139
+ package problems16_2;
140
+
141
+
142
+
143
+ import java.util.InputMismatchException;
144
+
145
+ import java.util.Scanner;
146
+
147
+
148
+
149
+ public class StartUp{
150
+
151
+
152
+
153
+ public static void main(String[] args) {
154
+
155
+ Scanner stdIn = new Scanner(System.in);
156
+
157
+
158
+
159
+ System.out.println("二つの整数値を入力してください。");
160
+
161
+ int a;
162
+
163
+ int b;
164
+
165
+ try {
166
+
167
+ a = stdIn.nextInt();
168
+
169
+ b = stdIn.nextInt();
170
+
171
+
172
+
173
+ MulDiv2.timeNumbers(a, b);
174
+
175
+ MulDiv2.divideNumbers(a, b);
176
+
177
+ }catch(ArithmeticException e) {
178
+
179
+ System.out.println("0での割り算はできません。");
180
+
181
+
182
+
183
+ }catch(InputMismatchException e) {
184
+
185
+ System.out.println("整数値ではありません。");
186
+
187
+
188
+
189
+ }finally {
190
+
191
+ System.out.println("プログラムを終了します。");
192
+
193
+ }
194
+
195
+
196
+
197
+
198
+
199
+
200
+
201
+ }
202
+
203
+ }
204
+
205
+
206
+
207
+ ```
208
+
209
+ ```ここに言語を入力
210
+
211
+ package problems16_2;
212
+
213
+
214
+
215
+ public class MulDiv2 {
216
+
217
+
218
+
219
+ static int timeNumbers(int a, int b) {
220
+
221
+ return a*b;
222
+
223
+ }
224
+
225
+
226
+
227
+ static double divideNumbers(int a, int b) {
228
+
229
+ return (double)a/b;
230
+
231
+ }
232
+
233
+
234
+
235
+ static void showResults(int a, int b) {
236
+
237
+ System.out.println(a + " × " + b + " = " + timeNumbers(a,b) );
238
+
239
+ System.out.println(a + " ÷ " + b + " = " + divideNumbers(a,b));
240
+
241
+ }
242
+
243
+ }
244
+
245
+
246
+
247
+ ```

1

文法の修正

2018/05/11 13:49

投稿

Tazusa
Tazusa

スコア41

test CHANGED
File without changes
test CHANGED
@@ -106,8 +106,6 @@
106
106
 
107
107
  ```
108
108
 
109
- package problems16_2;
110
-
111
109
 
112
110
 
113
111
  public class MulDiv2 {