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
hide comments
Arnab Mitra:
2014-12-23 14:53:59
use printf for rounding off to 2 decimal places |
|
Prakhar Dikshit:
2014-08-15 12:43:02
how to round off 7.40741 to 7.41 |
|
Mitch Schwartz:
2014-01-08 21:59:28
Moved to tutorial. |
|
Zenith:
2014-01-05 16:45:05
good way to calculate high school grade ;-) |
|
NZEC:
2014-01-03 22:17:56
surely for tutorial |
|
topgun:
2014-01-02 05:21:31
hey is there some problem or something special in terms of input/output .... feeling really confused and so many wa's ?! |
|
abhi:
2013-12-29 11:54:31
easy 1 |
|
Sourangsu :
2013-12-28 20:58:21
Seems like someone's homework problem....weak test cases Last edit: 2013-12-28 21:00:56 |
|
Pranye Mawai:
2013-12-26 07:04:53
tutorial stuff.. :P |
|
ritz:
2013-12-25 19:25:20
got two wa's..and den figured out that \n was missing :D
|
Added by: | Pandian |
Date: | 2013-12-19 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |
Resource: | Own |