Answer to Question #161051 in C++ for Naveen K Madival

Question #161051

Write a program to calculate the SPI(semester performance index) and CPI(Cumulative Performance Index) of a student taking N courses in a semester. Each course has a specified weight, termed as credit and a student secures a letter grade in that course as per the Grading System.


The Grading System is as follows:

Letter Grade Numerical Grade

A  10

B  9

.  .

.  .

K  0

Note that the numerical grade can be obtained from the letter grade using arithmetic operations on char type data.


1
Expert's answer
2021-02-05T08:07:00-0500
#include <iostream>
#include <iomanip>
using namespace std;
int main() {
    int n, a[10], c = 0, i, t;
    char B[10];
    double sp, s = 0, cp, tt;
    cout << "Enter the number of courses: "; cin >> n;
    
    for(i = 0; i < n; i++) {
        cout << "grades for the " << i + 1  << " - subject\n";
        cout << "Letter Grade: "; cin >> B[i];
        cout << "Numerical Grade: "; cin >> a[i];
    }
    
    cin >> tt >> t;
    for (i = 0; i < n; i++) {
        c = c + a[i];
        switch(B[i]) {
            case 'A' : s += 10*a[i]; break;
            case 'B' : s += 9*a[i]; break;
            case 'C' : s += 8*a[i]; break;
            case 'D' : s += 7*a[i]; break;
            case 'E' : s += 6*a[i]; break;
            case 'F' : s += 5*a[i]; break;
            case 'G' : s += 4*a[i]; break;
            case 'H' : s += 3*a[i]; break;
            case 'I' : s += 2*a[i]; break;
            case 'J' : s += 1*a[i]; break;
            case 'K': s+=0*a[i]; break;
        }
    }
    sp = s / c;
    cp = (s + tt * t) / (c + t);
    cout << fixed << setprecision(2) << sp << " " <<cp;
    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog