A sentimental robot

Score Management[Three dimensional] 본문

Java

Score Management[Three dimensional]

GOD03219 2017. 12. 28. 11:51

import java.util.Scanner;

public class Hello2 {
 public static void main(String[] args) {

  Scanner sc=new Scanner(System.in);
  System.out.print("반의 수 :");
  int clas;
  clas=sc.nextInt();


  System.out.print("학생 수:");
  int student;
  student=sc.nextInt();


  int [][][]score=new int[clas][student][4];
  float [][]avg=new float[clas][student];
  String [][]name=new String[clas][student];
  String []sconame={"Class","Name","kor","eng","mat","total","avg"};


  for(int i=0; i<score.length ;i++) 
  {
   System.out.println(sconame[0]+" : "+(i+1)+"반");


   for(int j=0; j<score[i].length ;j++)     // i+1반의 학생 이름 입력
   {
    
    System.out.print(sconame[1]+" : ");
    name[i][j]=sc.next();
    
    for(int k=0; k<score[i][j].length-1 ;k++){  // 국,영,수 점수만 입력(합계는 입력대상이 아님-1)
     
     System.out.print(sconame[k+2]+" : ");
     score[i][j][k]=sc.nextInt();
     score[i][j][3]+=score[i][j][k];
    }
    
    avg[i][j]=score[i][j][3]/3;
   }
   
  
   
  }


  // print ALL


  for(int i=0; i<score.length ;i++)
  {
   System.out.print(sconame[0]+" : "+(i+1)+"반");


   for(int j=0; j<score[i].length ;j++)

   {
    
    System.out.print(sconame[1]+" : ");
    System.out.println(name[i][j]);
    
    for(int k=0;k<score[i][j].length;k++){
     
     System.out.print(sconame[k+2]+" : ");
     System.out.println(score[i][j][k]);


    }


    System.out.print(sconame[6]+" : ");

    System.out.println(avg[i][j]);


   }

   
  
  }

 }
}

'Java' 카테고리의 다른 글

Object-oriented style score management  (0) 2017.12.28
The elements of "Class"  (0) 2017.12.28
Score Management[Two dimensional]  (0) 2017.12.28
String class  (0) 2017.12.28
foreach문  (0) 2017.12.28