JAVA2009. 11. 21. 13:56
간단한 성적 출력 Java

2009/01/18 15:23

작성자: 베레(lsj403)

class Score {

     public static void main(String[] args){

         int cnt = args.length; 
         int total = 0;
         float avg = 0;

         String[] subject = new String[cnt/2];
         int[] score = new int[cnt/2];

         for (int i=0; i              if (i%2==0) { 
                  subject[i/2] = args[i];
              } else {
                score[i/2] = Integer.parseInt(args[i]);
                total += score[i/2];
              }
         }

         avg = total / (float)cnt * 2;

         System.out.println("================");
         System.out.println("과목\t점수");
         System.out.println("================");
         for (int i=0; i              System.out.println(subject[i]+"\t"+score[i]);
         }
         System.out.println("================");
         System.out.println("총점\t"+total);
         System.out.println("평균\t"+avg);
         System.out.println("================");

     } // main

} // class


'JAVA' 카테고리의 다른 글

성적표 출력 실습  (0) 2009.11.21
점과 점 사이의 거리 출력 실습  (0) 2009.11.21
Random을 이용한 난수 발생  (0) 2009.11.21
입력을 받아 구구단 출력  (0) 2009.11.21
구구단 출력 실습  (0) 2009.11.21
Posted by Tiwaz