mardi 15 décembre 2020

C++ grade calculator using array

I'm trying to create this student calculator, however, I'm having a problem on how would I compute the overall. and also the solution for total number of passers(totalnpa) & total number of failures(totalf).

enter image description here

#include <iostream>
using namespace std; 
int main(){
    int studNo[] = {1111,2222,3333,4444,5555};

    float overall, spr;
    float prelim[5] = {80, 70, 85, 90, 95};
    float midterm[5] = {90, 65, 85, 90, 85};
    float finals[5] = {70, 80, 90, 90, 85};
    float totalspr=0, totalnpa=0, totalnof=0;

    cout << "     Student Grades 2020" << endl; 
    cout << "\n  Student No." << "\t        Prelim" << "\tMidterm" << "    Finals" << "    Overall" << "    Remark"<<endl; 

    for (int i=0; i <=4; i++ ) {
        overall= 0.20 * prelim + 0.30 * midterm + 0.50 * finals;
        spr=5;
        totalspr+=spr;
        totalnpa+=
        totalf
    
        if(overall >=75)
        {
        cout << "You Passed";
    }
    else if(overall <=75)
    {
        cout << "You Failed";
        }   
    
            cout << studNo << "\t" << prelim[i] << "\t" << midterm[i] << "\t    " << finals[i] << "\t" << overall << "\t" << remark << "\t" <<endl;
    }
cout << "\n   Summary : " << endl;
   cout << "\tTotal Students Printed : " << totalspr << endl;
   cout << "\tTotal Number of Passers : " << totalnpa << endl;
   cout << "\tTotal Number of Failures : " << totalf << endl;


cout << "\nProgrammed by: ";
          
    return 0;
}   

This is my code so far, it is still incomplete as I'm having a hardtime on my "for (int),totalspr, totalnpa, totalf" and the overall computations(can't make the operators right somehow).

Aucun commentaire:

Enregistrer un commentaire