# CMRGPACA-Editorial

Practice
Setter: Charan Narukulla
Tester: Abhilash Movva

Cake-Walk

Math

# PROBLEM:

There are N subjects. respective subject grades and credits were given to you. Credits for each subject are based on credits for that subject and grade obtained.(check CMRTC GPA CALCULATOR | CodeChef)
Credit points (CP) = grade point (GP) x credits for that subject(CS).

GPA= Σ CP/ Σ CS

# EXPLANATION:

Perform char/string matching to get grade and credits.
First calculate CP for every subject by using formula mentioned. Calculate total credits CS and final GPA= Σ CP/ Σ CS.

Setter's Solution

#include <bits/stdc++.h>
using namespace std;

``````    if(grade == "o" || grade == "O" ) return 10;
``````

}

int main(){
int t;
cin >> t;
while(t–){
int numOfSubjects,i; cin >> numOfSubjects;
float cp=0, gp, cs, cpSum=0, csSum=0;
string g;
// char g;
int pass=1;
for(i=0; i<numOfSubjects; i++) {
cin >> g >> cs;
gp = calc(g);
if(gp==0){
pass=0;

``````        }
cp = gp * cs;
cpSum += cp;
csSum += cs;
}
if(pass)
cout << fixed << setprecision(2) << cpSum / csSum << endl;
else
std::cout << "FAIL" << std::endl;
}
return 0;
``````

}