質問編集履歴

2

追記

2020/07/09 13:40

投稿

CarpeDiemnosiru
CarpeDiemnosiru

スコア4

test CHANGED
File without changes
test CHANGED
@@ -187,3 +187,139 @@
187
187
  Kilmeny 42 32.0
188
188
 
189
189
  Marigold 64 43.7
190
+
191
+ ###追記
192
+
193
+ ```Java
194
+
195
+ package hello;
196
+
197
+
198
+
199
+ public class Seiseki2 {
200
+
201
+
202
+
203
+ public static void main(String[] args) {
204
+
205
+
206
+
207
+ int i = 0;
208
+
209
+ double sum = 0;
210
+
211
+ double average = 0;
212
+
213
+ double sd = 0;
214
+
215
+ double ssum = 0;
216
+
217
+
218
+
219
+ String names[] = new String[args.length/2];
220
+
221
+ double score[][] = new double[2][args.length/2];
222
+
223
+
224
+
225
+ for(i = 0; i < args.length; i += 2 ) {
226
+
227
+ names[i/2] = args[i];
228
+
229
+ score[0][i/2] = Double.parseDouble(args[i + 1]);
230
+
231
+ sum += score[0][i/2];
232
+
233
+
234
+
235
+ }for(i = 0; i < args.length/2; i ++ ) {
236
+
237
+ average = sum / (args.length/2);
238
+
239
+ ssum += sqr(score[0][i] - average);
240
+
241
+
242
+
243
+ }for(i = 0; i < args.length/2; i ++ ) {
244
+
245
+ sd = Math.sqrt(ssum / (args.length/2));
246
+
247
+ }for(i = 0; i < args.length/2; i ++ ) {
248
+
249
+ double hensachi = 50 + ((score[0][i] - average)/sd )* 10;
250
+
251
+ score[1][i] = hensachi;
252
+
253
+
254
+
255
+ } System.out.println("Average = " + average);
256
+
257
+ System.out.println("Standard Deviation = " + sd);
258
+
259
+ for(i = 0; i < args.length/2; i ++) {
260
+
261
+
262
+
263
+ double scoreX = score[0][i];
264
+
265
+ String s = new java.text.DecimalFormat("0.#").format(scoreX );
266
+
267
+ double scoreY = score[1][i];
268
+
269
+ String ss = new java.text.DecimalFormat("0.#").format(scoreY);
270
+
271
+
272
+
273
+ System.out.print(" " + names[i] + " ");
274
+
275
+ System.out.print(s + " ");
276
+
277
+ System.out.println(ss);
278
+
279
+
280
+
281
+ }
282
+
283
+
284
+
285
+ }
286
+
287
+
288
+
289
+ private static double sqr(double d) {
290
+
291
+ return d * d;
292
+
293
+ }
294
+
295
+
296
+
297
+ }
298
+
299
+
300
+
301
+ ```
302
+
303
+ 解決しました。ありがとうございます。
304
+
305
+ 結果は以下の通りになりました。
306
+
307
+ Average = 75.875
308
+
309
+ Standard Deviation = 18.850978091335207
310
+
311
+ Anne 100 62.8
312
+
313
+ Glbert 99 62.3
314
+
315
+ Diana 60 41.6
316
+
317
+ Emily 89 57
318
+
319
+ Bryce 79 51.7
320
+
321
+ Jane 74 49
322
+
323
+ Kilmeny 42 32
324
+
325
+ Marigold 64 43.7

1

コードの修正

2020/07/09 13:40

投稿

CarpeDiemnosiru
CarpeDiemnosiru

スコア4

test CHANGED
File without changes
test CHANGED
@@ -42,6 +42,8 @@
42
42
 
43
43
  double sd = 0;
44
44
 
45
+      double ssum = 0;
46
+
45
47
 
46
48
 
47
49
  String names[] = new String[args.length/2];
@@ -63,8 +65,6 @@
63
65
  }for(i = 0; i < args.length/2; i ++ ) {
64
66
 
65
67
  average = sum / (args.length/2);
66
-
67
- double ssum = 0;
68
68
 
69
69
  ssum += sqr(score[0][i] - average);
70
70