一番下にtotalとaveの平均値を求めたいのですがどうすればいいでしょうか
Java
1コード 2import java.util.Scanner; 3 4public class Sample01 { 5 public static void main(String[] args) { 6 final int MEMBER = 4; 7 final int SUBJECT = 3; 8 int[][] score = new int[MEMBER][SUBJECT]; 9 int[] total = new int[MEMBER]; 10 int[] point = new int[SUBJECT]; 11 Scanner sc = new Scanner(System.in); 12 13 for (int i = 0; i < MEMBER; i++) { 14 System.out.println("****Member" + (i + 1) + "****"); 15 for (int j = 0; j < SUBJECT; j++) { 16 System.out.print("Input point of subject" + (j + 1) + ":"); 17 score[i][j] = sc.nextInt(); 18 total[i] += score[i][j]; 19 point[j] += score[i][j]; 20 } 21 } 22 System.out.println("*Name****S1*****S2*****S3*****Total****AVE"); 23 for (int i = 0; i < MEMBER; i++) { 24 System.out.print(" Members" + (i + 1)); 25 for (int j = 0; j < SUBJECT; j++) { 26 System.out.print(" " + score[i][j] + " "); 27 } 28 double avg = (double)total[i] / SUBJECT; 29 System.out.println(total[i] + " " + avg); 30 } 31 double ave0 = (double)point[0] / MEMBER; 32 double ave1 = (double)point[1] / MEMBER; 33 double ave2 = (double)point[2] / MEMBER; 34 System.out.println("-----------------------------------------"); 35 System.out.println("AVG " + ave0 + " " + ave1 + " " + ave2); 36 } 37}
現在起きている問題は何でしょうか
あなたの回答
tips
プレビュー