Question: rust Problem 1 . Minimum Grade Given the minimum GPA criteria for this semester and the grades of all subjects taken except one, output the

rust
Problem 1. Minimum Grade
Given the minimum GPA criteria for this semester and the grades of all subjects taken except one, output the minimum letter grade required for the remaining subject to meet the minimum GPA criteria. The grade conversion table according to the scores is as follows: The GPA for this semester is calculated as (the sum of (credits x grade of each subject) over all subjects)-: (total credits taken this semester), rounded down to the third decimal place. If the GPA for this semester exceeds the minimum GPA criteria, it is considered to have met the criteria. However, be careful of floating-point errors when using floating-point types.
(letter, grade)-(A+,4.50),(A0,4.00),(B+,3.50),(B0,3.00),(C+,2.50),(C0,2.00),(D+,1.50),(D0,1.00),(F,0.00)
Input
The first line contains the number of subjects taken this semester N and the minimum GPA criteria X separated by a space (2<= N <=24; 0.00<= X <=4.50; X is a real number given up to two decimal places).
From the second line to the N 1th line, the credits ci(i) and the letter grade gi of each subject are given separated by a space (1<= ci <=6; gi is one of A+, A0, B+, B0, C+, C0, D+, D0, F).
The next line gives the credits L of the remaining one subject (1<= L <=6).
Output
Output the minimum letter grade required for the remaining subject to meet the minimum GPA criteria.
If it is impossible to meet the criteria regardless of the grade received, print "impossible".
Example 1
Input
53.59
4 A+
3 B+
3 C+
1 D0
3
Output
A+
If the grade for the remaining subject is A+, the GPA for this semester would be ((4\times 4.5)+(3\times 3.5)+(3\times 2.5)+
(1\times 1.0)+(3\times 4.5))-: (4+3+3+1+3)=3.60714285... rounded down to the third decimal place, 3.60.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!