Last active
August 29, 2015 14:08
-
-
Save mneko22/d0c510c6e5b547653e0a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Testjg{ | |
public static void main(String[] args)throws IOException{ | |
int temp = 0; //配列の中の数値を入れておく変数 | |
BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); | |
System.out.println("何人分の点数を入れますか"); | |
//キーボードで入力された分だけの引き出しをもつ配列(タンス)を作成 | |
int kazu = Integer.parseInt(br.readLine()); | |
int[] hairetu = new int[kazu]; | |
//キーボードで配列(の引き出し)に点数を入れていく | |
System.out.println("人数分の点数を順番に入力してください"); | |
for (int i = 0; i < hairetu.length; i++){ | |
hairetu[i] = Integer.parseInt(br.readLine()); | |
temp += hairetu[i]; //引き出しごとの配列の数値を変数に加算していく | |
} | |
//平均を求める変数に,全ての引き出しの合計の「temp」と、引き出しの数(配列の長さ「hairetu.length」)平均を求める | |
double ave = temp / hairetu.length; | |
System.out.println("平均点は:" + ave + "です"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment