Submit | All submissions | Best solutions | Back to list |
GPACALC - Calculate your GPA |
Design a calculator to calculate your GPA. Possible grades are S, A, B, C, D and E. S corresponds to 10 credits, A to 9, B to 8, C to 7, D to 6 and E to 5. There are n subjects. Each subject has a number of credits and the grade obtained by the student.
GPA of the student is the summation of [[grades obtained multiplied by the number of credits for each subject]] divided by the total number of credits. For example, if input is n = 3 and three subjects have credits 3, 4 and 5. A student has obtained grade S, A and B respectively, then GPA = (3*10 + 4*9 + 5*8)/(3+4+5)
Input
First line consists of t, the number of test cases (1 <= t <= 20). Each test case starts with n, the number of subjects (1 <= n <= 16). The next n lines consist of credits for that subject followed by grade obtained by the student (1 <= credits <= 10 and grade will be one among S, A, B, C, D and E)
Output
For each test case, print the GPA of the student rounded off to two decimal places.
Example
Input: 1 12 4 D 1 E 1 S 3 D 1 E 2 A 4 A 4 A 3 C 1 C 1 B 2 D Output: 7.41
Added by: | Pandian |
Date: | 2013-12-19 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |
Resource: | Own |
hide comments
|
|||||||
2013-12-24 06:39:24 Saimadhav Heblikar
tutorial stuff |
|||||||
2013-12-23 19:22:27 Ashwini
ac in first attempt |
|||||||
2013-12-23 14:15:57 Sundar
Simple! My half century! :) |
|||||||
2013-12-23 13:29:46 [Lakshman]
@Harish Viswanathan PLease post your code in forum. Your code is correct you are doing silly mistake. |
|||||||
2013-12-23 12:03:07 Prashant Kiran
Finally AC...taking as string cost me 9 WAs |
|||||||
2013-12-23 08:59:09 utpal kumar jha
@Harish use double accordingly no need of floor.. easy Ac :) |
|||||||
2013-12-23 08:41:32 Harish Viswanathan
i rounded off correctly i think. what is wrong in my program? <snip> Last edit: 2023-03-31 23:49:36 |
|||||||
2013-12-22 09:39:30 Kanish
easy one !!!! |
|||||||
2013-12-22 09:28:10 Prashant Kiran
@yashwant can you tell me whats the error..it has already cost me so many WA...TIA |
|||||||
2013-12-22 09:16:50 yaswanth
@ prashant I think rounding off is not the problem. I did the same thing as u did for rounding off. But AC. |