카테고리 없음

[백준] 25206번 너의 평점은

메델 2023. 12. 5. 05:31
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    	Scanner kb = new Scanner(System.in);
    	
    	String scoreList[] = {"A+", "A0", "B+", "B0", "C+", "C0", "D+", "D0", "F", "P"};
    	double scoreList2[] = {4.5, 4.0, 3.5, 3.0, 2.5, 2.0, 1.5, 1.0, 0.0, 0.0};
    	double total = 0;
    	double creditTotal = 0;
    	for(int i=0; i<20; i++) {
    		String subject = kb.next();
    		double credit = kb.nextDouble();
    		String score = kb.next();
    		
    		for(int j=0; j<scoreList.length; j++) {
    			if(score.equals(scoreList[j])) {
    				if(j != 9) {
        				double num = scoreList2[j]* credit;
        				total += num;
        				creditTotal += credit;
    				}
    			}
    		}
    	}
    	
    	System.out.println(total/creditTotal);

    }
}