Participate in exhilarating programming contests, solve unique algorithm and data structure challenges and be a part of an awesome community.

Jenith is a student of CSE of Metropolitan University (MU). Recently her fifth term’s result has been published. She obtained CGPA 4 out of 4. Her classmates ask her to calculate their CGPA. Actually she helps her friends to calculate their CGPA from the first term. Sometimes she feels bore, so she wants to write a program now that will help her friends to calculate their CGPA. As you are a very good programmer she needs your help.

CGPA stands for “Cumulative Grade Point Average”. It is calculated based on all the courses you take along with the total number of credit hours. The total marks or numeral grades of a course is multiplied by the total credits of that course. Then summing the results of all the courses divide by the total credits of a term or semester you will get your CGPA.

In Metropolitan University important courses including major and non-major courses carry 3 to 4 credits and some less important courses including lab courses carry 1 to 2 credits.

Marks Range | Grade | Grade Point |
---|---|---|

80-100 | A+ | 4.00 |

75-79 | A | 3.75 |

70-74 | A- | 3.50 |

65-69 | B+ | 3.25 |

60-64 | B | 3.00 |

55-59 | B- | 2.75 |

50-54 | C+ | 2.50 |

45-49 | C | 2.25 |

40-44 | C- | 2.00 |

0-39 | F | 0.00 |

The first line of input contains an integer **T** (T ≤ 50) denoting the number of test cases. Next line contains an integer C the number of courses you take in a term or semester. Next C lines contains two numbers (can be float or double) **m**, **n** (0 ≤ m ≤ 100, n ≥ 1), the marks of a course and the credit of that course.

For each test case print the case no and print the floating point result R (two digits after decimal) that denotes your CGPA. If your input m contains less than 40 then print "Sorry, you have failed in F courses!" Where F is an integer that denotes the number of courses you have failed.

Input | Output |
---|---|

3 4 79.5 3 88 3 100 3 75 2 5 97 3 92 1.5 69 2 75 3 55 3 4 56.5 2 55.5 3 36 3 25 4 | Case 1: 3.89 Case 2: 3.52 Case 3: Sorry, you have failed in 2 courses! |

Note: If you have failed in 1 course, then you have to print "Sorry, you have failed in 1 course!". Otherwise print "Sorry, you have failed in F courses!", where F denotes the the total number of courses you have failed.

82% Solution Ratio

nazmul.me92Earliest,

Nasif_44thFastest, 0.0s

Mili290Lightest, 0 B

touhidurrrShortest, 267B

Login to submit

It is a very easy problem. Needs 2 loops, 1 for test cases another one for number of courses and som...

Toph uses cookies. By continuing you agree to our Cookie Policy.