トップ・ページの表示 注意書きの表示 掲示板に書き込む前に必ず この ”注意書き”を お読み下さい.

"伊邪那"

   
   

ページの表示順:{ 新しい順/ 古い順}.
初期・ページの表示・位置:{ 先頭ページ/ 末尾ページ}.
1ページ内のスレッド表示数:







<Number>: [00000A5E]  <Date>: 2021/07/17 16:59:05
<Title>: Javaデモ/「平均、分散(母分散)」
<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);
  }
}

Block( Address 00000A5F Identity 00000A5E )






ページの表示順:{ 新しい順/ 古い順}.
初期・ページの表示・位置:{ 先頭ページ/ 末尾ページ}.
1ページ内のスレッド表示数:

   
   

管理者用 Password:

  




SMT Version 8.022(+A) Release M6.
Author : amanojaku.


- Rental Orbit Space -