質問編集履歴
3
解決しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -12,55 +12,4 @@
|
|
12
12
|
現在、上記のようなプログラムを作成中ですが
|
13
13
|
平均を超えた数(←)のところでつまってます。
|
14
14
|
|
15
|
-
ご教授いただけるとうれしいです。よろしくお願いします。
|
15
|
+
ご教授いただけるとうれしいです。よろしくお願いします。
|
16
|
-
|
17
|
-
|
18
|
-
```ここに言語を入力
|
19
|
-
class Sumtoave{
|
20
|
-
public static void main(String args[])throws IOException{
|
21
|
-
|
22
|
-
int sum=0;
|
23
|
-
int ave=0;
|
24
|
-
int calcu=0;
|
25
|
-
|
26
|
-
//キーボード入力して文字を数字に変換
|
27
|
-
|
28
|
-
System.out.println("整数の個数を入力");
|
29
|
-
BufferedReader br = new BufferedReader( new InputStreamReader(System.in));
|
30
|
-
|
31
|
-
String str=br.readLine();
|
32
|
-
int input=Integer.parseInt(str);
|
33
|
-
|
34
|
-
//合計と平均を求める
|
35
|
-
|
36
|
-
for(int x=0;x<input;x++){
|
37
|
-
System.out.println((x+1)+"つ目の整数");
|
38
|
-
int t=Integer.parseInt(br.readLine());
|
39
|
-
sum+=t;
|
40
|
-
}
|
41
|
-
ave=sum/input;
|
42
|
-
/*
|
43
|
-
|
44
|
-
//配列に入れる
|
45
|
-
int [] num =new int[input];
|
46
|
-
|
47
|
-
//入力した数字が平均を超えているか
|
48
|
-
|
49
|
-
if(ave<input){
|
50
|
-
str=br.readLine();
|
51
|
-
int n=Integer.parseInt(str);
|
52
|
-
calcu=n;
|
53
|
-
}else{
|
54
|
-
System.out.println("ちがう");
|
55
|
-
}
|
56
|
-
*/
|
57
|
-
|
58
|
-
//表示
|
59
|
-
System.out.println("合計"+sum);
|
60
|
-
System.out.println("平均"+ave);
|
61
|
-
System.out.println("超えた"+calcu);
|
62
|
-
|
63
|
-
|
64
|
-
}
|
65
|
-
}
|
66
|
-
```
|
2
追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -14,10 +14,8 @@
|
|
14
14
|
|
15
15
|
ご教授いただけるとうれしいです。よろしくお願いします。
|
16
16
|
|
17
|
-
import java.io.BufferedReader;
|
18
|
-
import java.io.IOException;
|
19
|
-
import java.io.InputStreamReader;
|
20
17
|
|
18
|
+
```ここに言語を入力
|
21
19
|
class Sumtoave{
|
22
20
|
public static void main(String args[])throws IOException{
|
23
21
|
|
@@ -64,4 +62,5 @@
|
|
64
62
|
|
65
63
|
|
66
64
|
}
|
67
|
-
}
|
65
|
+
}
|
66
|
+
```
|
1
添削お願いします。
title
CHANGED
File without changes
|
body
CHANGED
@@ -12,4 +12,56 @@
|
|
12
12
|
現在、上記のようなプログラムを作成中ですが
|
13
13
|
平均を超えた数(←)のところでつまってます。
|
14
14
|
|
15
|
-
ご教授いただけるとうれしいです。よろしくお願いします。
|
15
|
+
ご教授いただけるとうれしいです。よろしくお願いします。
|
16
|
+
|
17
|
+
import java.io.BufferedReader;
|
18
|
+
import java.io.IOException;
|
19
|
+
import java.io.InputStreamReader;
|
20
|
+
|
21
|
+
class Sumtoave{
|
22
|
+
public static void main(String args[])throws IOException{
|
23
|
+
|
24
|
+
int sum=0;
|
25
|
+
int ave=0;
|
26
|
+
int calcu=0;
|
27
|
+
|
28
|
+
//キーボード入力して文字を数字に変換
|
29
|
+
|
30
|
+
System.out.println("整数の個数を入力");
|
31
|
+
BufferedReader br = new BufferedReader( new InputStreamReader(System.in));
|
32
|
+
|
33
|
+
String str=br.readLine();
|
34
|
+
int input=Integer.parseInt(str);
|
35
|
+
|
36
|
+
//合計と平均を求める
|
37
|
+
|
38
|
+
for(int x=0;x<input;x++){
|
39
|
+
System.out.println((x+1)+"つ目の整数");
|
40
|
+
int t=Integer.parseInt(br.readLine());
|
41
|
+
sum+=t;
|
42
|
+
}
|
43
|
+
ave=sum/input;
|
44
|
+
/*
|
45
|
+
|
46
|
+
//配列に入れる
|
47
|
+
int [] num =new int[input];
|
48
|
+
|
49
|
+
//入力した数字が平均を超えているか
|
50
|
+
|
51
|
+
if(ave<input){
|
52
|
+
str=br.readLine();
|
53
|
+
int n=Integer.parseInt(str);
|
54
|
+
calcu=n;
|
55
|
+
}else{
|
56
|
+
System.out.println("ちがう");
|
57
|
+
}
|
58
|
+
*/
|
59
|
+
|
60
|
+
//表示
|
61
|
+
System.out.println("合計"+sum);
|
62
|
+
System.out.println("平均"+ave);
|
63
|
+
System.out.println("超えた"+calcu);
|
64
|
+
|
65
|
+
|
66
|
+
}
|
67
|
+
}
|