Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is a question for C++ Grading Schema: In a separate function you will imple

ID: 663820 • Letter: T

Question

This is a question for C++

Grading Schema: In a separate function you will implement a grading schema. Write a program that reads a student’s name together with his or her test score from a file given by the user. The first two values in the file will represent the number of students followed by the number of tests. The program should then compute the average test score for each student and assign the appropriate grade (A, B, C, D, E or F) as well as the average of each test. Your program must perform the following functions. a) A void function calculateAverage, to determine the average of the test scores for each student. b) A value-returning function, calculateGrade, to determine and return each student’s grade letter. c) A void function calculateTestAvg that calculates the average of all tests and overall average of students. d) A void function printGrades that prints the grades values, average marks and grade letter followed by the average of all tests and students.

Explanation / Answer

#include<iostream>
#include<cmath>
#include<string>
#include<fstream>
using namespace std;
double calculateAverage1(double testVal1, double testVal2, double testVal3, double testVal4, double testVa5);
char calculateGrade(double average);
double calculateAverage1(double testVal1, double testVal2, double testVal3, double testVal4, double testVa5)
   {
      int average1;
          average1=(testVal1+testVal2+testVal3+testVal4+testVa5)/5; //calculating the average1s
           return average1;
   }
   char calculateGrade(double average1)
       {
          char grade1;
               if (average1 >= 90)
                      grade1='A';
               else if(average1>=80)
                      grade1='B';
               else if(average1>=70)
                       grade1='C';
               else if(average1>=60)
                      grade1='D';
               else
                      grade1='F';
          return grade1;
   }

   int main()
   {
           double testVal1, testVal2, testVal3, testVal4, testVa5;
           double average1;
           double classaverage1=0;
           double count=0;
           char grade1;
           string name1;
           ifstream infile1;
          ofstream outfile1;
           infile1.open("c:\testScores.txt");
           outfile1.open("c:\average1s.txt");
           outfile1<<fixed<<showpoint<<setprecision(2);
        if (!infile1)
        {
               cout<<"cannot open the input file. please ensure that the file "<<"testScores is in c:/"<<endl;
           return -1;
        }

      outfile1<<"Student testVal1 testVal2 testVal3 testVal4 testVa5 average1 grade1"<<endl;
           while(!infile1.eof())
               {
                       infile1>> name1>> testVal1>> testVal2>> testVal3 >> testVal4 >>testVa5;
                      outfile1<<name1<<' '<<testVal1<<' '<<testVal2<<' '<<testVal3<<' '<<testVal4<<' '<<testVa5<<' ';
                      average1=calculateaverage11(testVal1, testVal2, testVal3, testVal4, testVa5);
                       grade1=calculategrade1(average1);
                       classaverage1=classaverage1+average1;
                      count=count++;
                       outfile1<<average<<' '<<grade1<<endl;

               }

                       classaverage1=classaverage1/count;
                      outfile1<<' '<<"Class Average: "<<classaverage1;
              return 0;

  

   }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote