자바

import java.util.Scanner;
public class ex4 {

 /**
  * @param args
  */
 public static void main(String[] args) {
  // TODO Auto-generated method stub
  int a1,a2,a3,a4,a5,b,count,n;
  float hap,c;
  String a,f;
  count = 0;
  b = 0;
  n = 0;
  Scanner scan = new Scanner (System.in);
 
  do {
  System.out.println("교과목의 이름을 입력해주세요: ");
  f = scan.next();
   
   
  System.out.print("출석  ");
  a1 = scan.nextInt();
 
  System.out.print("과제 ");
  a2 = scan.nextInt();
 
  System.out.print("수시");
  a3 = scan.nextInt();
 
  System.out.print("중간 ");
  a4 = scan.nextInt();
 
  System.out.print("기말 ");
  a5 = scan.nextInt();
 
  hap = (float) (a1 + a2 + a3 + a4 + a5) /5;
 
  System.out.println(f + "총점 " + hap);
 
  if (hap >= 90)
  {System.out.println(f + "학점은 : A");
  n = 4;}
  else if (hap >= 80)
   {System.out.println(f +"학점은 : B");
  n = 3;}
  else if (hap >= 70)
   {System.out.println(f +"학점은 : C");
  n = 2;}
  else if (hap >= 60)
   {System.out.println(f + "학점은 : D");
  n = 1;}
  else
   {System.out.println(f +"학점은 : F");
  b = 0;}
 
  b += n;
 
  count++;
 
  System.out.print("계속하기를 원하세요?");
  System.out.print("그렇다면 y를 아니면 n를 입력하세요: ");
  a = scan.next();
  } while (a.equals("y"));
 
  {
   c =(float) b / count;
   System.out.println("평점 : " + c);
  }
 
 

 }

}



티스토리 툴바