掲示板に書き込む前に必ず この ”注意書き”を お読み下さい.
|
<Number>: [00000A5E]
<Date>: 2021/07/17 16:59:05
<Title>:
<Name>: amanojaku@管理人
|
|
|
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String[] name = new String[5];
int[] score = new int[5];
// System.out.println("5人分の名前と得点を入力");
int sum = 0;
for(int i = 0; i<score.length; i++) {
System.out.print("学生名を入力してください:");
name[i] = sc.next();
System.out.print("得点を入力してください:");
score[i] = sc.nextInt();
sum += score[i];
}
double ave = (double)sum/score.length;
double ds = 0;
for(int i = 0; i<score.length; i++) {
System.out.println("名前:"+name[i]+
" 得点:"+score[i]);
double dvt = score[i]-ave;
ds += dvt*dvt;
}
double dst = ds/score.length;
System.out.println("平均:"+ave);
System.out.println("分散(母分散):"+dst);
}
}
|
|
|
|
|
SMT Version 8.022(+A) Release M6.
Author : amanojaku.