Question

The Computer Science Instructor has just completed compiling all the grades for the C++ Programming class....

The Computer Science Instructor has just completed compiling all the grades for the C++ Programming class. The grades were downloaded into a file titled ‘studentGrades.txt’ (attached). Write a C++ Program that reads this file and calculates the following as described :

  1. The final semester numeric and letter grade (using 10 point scale) Calculated as follows:
    1. Labs 1-6 (worth 50% of final grade)
    2. Lab 7 is extra credit (worth 2 % of final grade OR replaces lowest lab grade – Select the option which results in the highest final semester grade.
    3. Quizzes (worth 10% of final grade after dropping the lowest 3 quiz grades)
    4. Midterm Exam (worth 20% of final grade)
    5. Final Exam (worth 20% of final grade)
    6. Survey (worth 1% of final grade)
  2. The program must use the arrays and functions provided in the driver program below.

Note : Hand check the final grades to verify your answers.

           Use the following driver to test your functions:

#include<iostream>

#include<fstream>

#include<iostream>

#include<string>

using namespace std;

const int MAX_NUM_STUDENTS = 24;

const int NUM_QUIZZES = 13;

const int NUM_LABS = 7;

// Returns the actual number of students in file.

int read_data(ifstream &input,

       string firstNames[], string lastNames[],

       string studentID[],

       double quizzes[][NUM_QUIZZES],

       double labs[][NUM_LABS],

       double midtermExam[],

       double finalExam[],

       double survey[]);

void analyze_grades(double quizzes[][NUM_QUIZZES],

       double labs[][NUM_LABS],

       double midtermExam[],

       double finalExam[],

       double survey[],

       char FinalSemesterGrades[],

       int &gradeA_cnt, int &gradeBC_cnt, int &gradeDF_cnt,

       double &highestGrade, double &lowestGrade,

       int numberOfStudents);

void display_results(string firstNames[], string lastNames[],

       string studentID[], char FinalSemesterGrades[],

       int gradeA_cnt, int gradeBC_cnt, int gradeDF_cnt,

       double highestGrade, double lowestGrade,

       int numberOfStudents);

int main()

{

       string firstNames[MAX_NUM_STUDENTS];

       string lastNames[MAX_NUM_STUDENTS];

       string studentID[MAX_NUM_STUDENTS];

       double quizzes[MAX_NUM_STUDENTS][NUM_QUIZZES],

              labs[MAX_NUM_STUDENTS][NUM_LABS],

              midtermExam[MAX_NUM_STUDENTS],

              finalExam[MAX_NUM_STUDENTS],

              survey[MAX_NUM_STUDENTS];

       char finalSemesterGrades[MAX_NUM_STUDENTS];

       int numberOfStudents = 0,

              double highestGrade = 0.0, lowestGrade = 0.0;

       int gradeA_cnt = 0, gradeBC_cnt = 0, gradeDF_cnt = 0;

       ifstream inFile;

       inFile.open("studentFinalGrades.txt", ios::in);

       if (!inFile.is_open())

       {

              cout << "Error: Cannot open file...Exiting." << endl;

              system("pause");

              exit(0);

       }

       //1. (30%) Call read_data(..) to read the input file and populate the arrays.

       //2. (50%) Call analyze_grades(..) to derive the final semester

       //student grades,

       //count # of A's, B/C's and D/F's grades in the class,

       //highestGrade - the highest grade in class.

       //lowestGrade - the lowest grade in class.

       //3. (20%) Call display_results(..) to display

       // A. All the student names/IDs with their final semester grades.

       // B. The count of A's, B/C's and D/F's grades in the class

       // C. The highest and lowest final semester grades

       inFile.close();

       system("pause");

       return 0;

}

studentFinalGrades.txt

LastName  FirstName     Student ID      Quiz01  Quiz02  Quiz03  Quiz04  Quiz05  Quiz06  Quiz07  Quiz08  Quiz09  Quiz10  Quiz11  Quiz12  Quiz13  Lab01   Lab02   Lab03   Lab04   Lab05   Lab06   Lab07   MidtermExam     FinalExam       InstructorSurvey
Alfred  Michael         4721            100     96      100     100     95      95      95      100     100     95      0       95      100     90      90      75      88      95      85      0       92              97              100
Ariet   Prajwol         3981            92      100     95      95      0       100     95      100     95      100     100     100     0       95      96      95      90      85      0       0       64              100             100
Arozo   Timothy         4469            100     100     95      95      100     95      95      100     100     100     100     95      100     95      95      95      75      89      92      0       57              100             0
Anderson        Kolby   4611            92      80      100     100     95      100     95      95      100     95      75      100     100     100     95      100     100     100     97      0       97              86              100
Anderson        Hunter  2027            96      100     100     95      100     100     0       100     85      0       90      100     100     90      98      95      76      87      95      0       89              85              100
Banks   Jeffrey         0656            100     68      85      90      95      60      90      85      100     80      100     90      100     90      72      60      45      92      65      70      65              72              100
Caya    Justin          7865            100     96      90      95      95      100     95      100     100     100     100     100     100     50      91      95      93      97      90      98      94              96              100
Dinan   Velina          6847            84      60      75      85      80      90      95      0       100     0       0       100     95      100     0       85      93      85      90      0       94              99              100
Hash    Gordon          8538            100     96      95      90      95      95      95      90      100     95      95      100     100     93      98      65      95      92      75      0       74              99              100
Heib    Yu-Chen         4441            96      100     100     100     90      100     95      0       100     95      90      100     100     95      78      93      92      95      90      0       91              97              100
Inman   Kyuyeon         9585            100     100     95      0       100     95      95      100     100     0       85      100     100     95      96      80      75      90      87      0       87              97              100
Patel   Jason           2231            100     88      90      95      95      100     90      0       95      90      80      95      100     20      0       55      20      77      0       0       76              78              100
Pokharel        Rachel  5574            100     92      95      95      95      100     95      100     100     0       90      100     100     95      98      80      90      89      90      0       75              89              0
Rafique Stefan          7373            100     92      95      95      95      100     95      100     100     0       90      100     100     95      98      80      90      89      90      0       94              96              0
Reaves  Nigel           1943            92      0       0       0       0       0       0       0       0       0       0       0       0       95      45      85      60      0       0       0       63              0               0
Robinson        Brian   2246            100     100     95      95      100     100     100     100     100     100     100     100     100     100     100     100     100     97      100     0       98              98              100
Widdifield      David   2616            96      72      95      95      90      85      95      80      100     100     70      95      100     100     100     85      80      97      100     0       80              98              0
0 0
Add a comment Improve this question Transcribed image text
Answer #1

INPUT
#######

Each field in input file are space separated as in screenshot below

studentFinalGrades Notepad File Edit Format View Help LastName FirstName studentID Quízel Quize2 Quize3 Quize4 Quízes Quize6

//##################PGM START ###################

#include<iostream>
#include<fstream>
#include<iostream>
#include<string>
#include<sstream>
#include <bits/stdc++.h>

using namespace std;

const int MAX_NUM_STUDENTS = 24;
const int NUM_QUIZZES = 13;
const int NUM_LABS = 7;
// Returns the actual number of students in file.

int read_data(ifstream &input,
       string firstNames[], string lastNames[],
       string studentID[],
       double quizzes[][NUM_QUIZZES],
       double labs[][NUM_LABS],
       double midtermExam[],
       double finalExam[],
       double survey[]);
     
void analyze_grades(double quizzes[][NUM_QUIZZES],
       double labs[][NUM_LABS],
       double midtermExam[],
       double finalExam[],
       double survey[],
       char FinalSemesterGrades[],
       int &gradeA_cnt, int &gradeBC_cnt, int &gradeDF_cnt,
       double &highestGrade, double &lowestGrade,
       int numberOfStudents);

void display_results(string firstNames[], string lastNames[],
       string studentID[], char FinalSemesterGrades[],
       int gradeA_cnt, int gradeBC_cnt, int gradeDF_cnt,
       double highestGrade, double lowestGrade,
       int numberOfStudents);
     
     


int main()
{

       string firstNames[MAX_NUM_STUDENTS];
       string lastNames[MAX_NUM_STUDENTS];
       string studentID[MAX_NUM_STUDENTS];
       double quizzes[MAX_NUM_STUDENTS][NUM_QUIZZES],
              labs[MAX_NUM_STUDENTS][NUM_LABS],
              midtermExam[MAX_NUM_STUDENTS],
              finalExam[MAX_NUM_STUDENTS],
              survey[MAX_NUM_STUDENTS];

       char finalSemesterGrades[MAX_NUM_STUDENTS];

       int numberOfStudents = 0;
       double highestGrade = 0.0, lowestGrade = 200.0;

       int gradeA_cnt = 0, gradeBC_cnt = 0, gradeDF_cnt = 0;
     
       ifstream inFile;
       inFile.open("studentFinalGrades.txt", ios::in);

       if (!inFile.is_open()){

              cout << "Error: Cannot open file...Exiting." << endl;
              system("pause");
              exit(0);
       }

       numberOfStudents=read_data(inFile,firstNames,lastNames,studentID,quizzes,labs,midtermExam,finalExam,survey);
     
       analyze_grades(quizzes,labs,midtermExam,finalExam,survey,finalSemesterGrades,gradeA_cnt,gradeBC_cnt,gradeDF_cnt,highestGrade,lowestGrade,numberOfStudents);
     
     
       display_results(firstNames,lastNames,studentID,finalSemesterGrades,gradeA_cnt,gradeBC_cnt,gradeDF_cnt,highestGrade,lowestGrade,numberOfStudents);
   
     
       inFile.close();
       system("pause");
       return 0;

}
int read_data(ifstream &input,
       string firstNames[], string lastNames[],
       string studentID[],
       double quizzes[][NUM_QUIZZES],
       double labs[][NUM_LABS],
       double midtermExam[],
       double finalExam[],
       double survey[]){
         
          //c stores the count of student records in file
       int c=0;
       string line;
       //ignore the header
       getline(input,line);
       //read line by line from the file
       while(getline(input,line)){
      
           stringstream ss(line);
           ss>>lastNames[c];
           ss>>firstNames[c];
           ss>>studentID[c];
           for(int i=0;i<13;i++){
               ss>>quizzes[c][i];
           }
      
           for(int i=0;i<7;i++){
               ss>>labs[c][i];
           }
          
           ss>>midtermExam[c];
           ss>>finalExam[c];
           ss>>survey[c];
           c+=1;
       }
       //return count of student record
       return c;

}
//funcntion to calculate grade
void analyze_grades(double quizzes[][NUM_QUIZZES],
       double labs[][NUM_LABS],
       double midtermExam[],
       double finalExam[],
       double survey[],
       char FinalSemesterGrades[],
       int &gradeA_cnt, int &gradeBC_cnt, int &gradeDF_cnt,
       double &highestGrade, double &lowestGrade,
       int numberOfStudents){
       double quizzTotal=0.0,labTotal=0.0;
       double total1=0.0,total2=0.0,total=0.0;
      
       //iterate for each student
          for(int i=0;i<numberOfStudents;i++){
              total1=0.0;
              total2=0.0;
              total=0.0;
              quizzTotal=0.0;
              labTotal=0.0;
             
              //sort the quizzess score
              sort(quizzes[i],quizzes[i]+NUM_QUIZZES);
         
              //sum all the quizzess except first 3 minimum score
              for(int j=3;j<13;j++){
                  quizzTotal+=quizzes[i][j];
           }
          
           //calculating sum of first 6 lab score
           for(int j=0;j<6;j++){
               labTotal+=labs[i][j];
           }
      
           //finding the total1
           total1=(0.1*(quizzTotal/10))+(0.2*finalExam[i])+(0.2*midtermExam[i])+(0.01*survey[i])+(0.5*(labTotal/6))+(0.02*labs[i][6]);
          
           //sorting lab score
           sort(labs[i],labs[i]+6);
          
           //ignore the smallest lab score in first 6 scores and add lab 7 score instead
           for(int j=1;j<7;j++){
               labTotal+=labs[i][j];
           }

           //finding the total
           total2=total1=(0.1*(quizzTotal/10))+(0.2*finalExam[i])+(0.2*midtermExam[i])+(0.01*survey[i])+(0.5*(labTotal/6));
          
           //finding maximum score
           if(total1>total2)
               total=total1;
           else
               total=total2;
              
           //finding the grade  
           if(total>90){
               FinalSemesterGrades[i]='A';
               gradeA_cnt+=1;
           }else if(total>80 && total<=90){
               FinalSemesterGrades[i]='B';
               gradeBC_cnt+=1;
           }else if(total>70 && total<=80){
               FinalSemesterGrades[i]='C';
               gradeBC_cnt+=1;
           }else if(total>60 && total<=70){
               FinalSemesterGrades[i]='D';
               gradeDF_cnt+=1;
           }else if(total<=60){
               FinalSemesterGrades[i]='F';
               gradeDF_cnt+=1;
           }
          
           //finding highest and lowest grade
           if(highestGrade<total)
               highestGrade=total;
              
           if(lowestGrade>total)
               lowestGrade=total;
          
       }
             

}

void display_results(string firstNames[], string lastNames[],
       string studentID[], char FinalSemesterGrades[],
       int gradeA_cnt, int gradeBC_cnt, int gradeDF_cnt,
       double highestGrade, double lowestGrade,
       int numberOfStudents){
       cout<<"Name\t\tID\tGrade\n";
       for(int i=0;i<numberOfStudents;i++){
           cout<<firstNames[i]<<" "<<lastNames[i]<<" "<<studentID[i]<<"\t"<<FinalSemesterGrades[i]<<"\n";
       }
       cout<<"\n\nGrade A Count: "<<gradeA_cnt<<"\n";
       cout<<"Grade B/C Count : "<<gradeBC_cnt<<"\n";
       cout<<"Grade D/F Count : "<<gradeDF_cnt<<"\n";
      
       cout<<"\nHighest Grade : "<<highestGrade<<"\n";
       cout<<"Lowest Grade     : "<<lowestGrade<<"\n";

}
      

//########################## PGM END ########################

OUTPUT
########

CAUsersVijinAW Documents\DevC+_Workspac Name Michael Alfred 4721 Prajwol Ariet 3981 Grade A ID Grade A Count: 2 Grade B/C Cou

Add a comment
Know the answer?
Add Answer to:
The Computer Science Instructor has just completed compiling all the grades for the C++ Programming class....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Microsoft Excel Question. I'm having trouble using the vlookup function, I have calculated a final numerical...

    Microsoft Excel Question. I'm having trouble using the vlookup function, I have calculated a final numerical grade for a hypothetical course, and and trying to use a set of numerical grades with their corresponding letter grades to get a vlookup function to return the letter grade from the numerical grade. However the function for some reason only returns the lowest value out of the set grades, not the closest match. Projects Classwork Teamwork/Integrity 100 100 A+ 98 A+ 97 A...

  • C++: Create a grade book program that includes a class of up to 20 students each...

    C++: Create a grade book program that includes a class of up to 20 students each with 5 test grades (4 tests plus a Final). The sample gradebook input file (CSCI1306.txt) is attached. The students’ grades should be kept in an array. Once all students and their test scores are read in, calculate each student’s average (4 tests plus Final counts double) and letter grade for the class. The output of this program is a tabular grade report that is...

  • 5. Mark’s class just took the admission test for business school and averaged 87.05. Chapter 10...

    5. Mark’s class just took the admission test for business school and averaged 87.05. Chapter 10 Data Set 2 contains the population of scores for the 10 other classes in Mark’s university. How did Mark’s class do? Class 1 Class 2 Class 3 Class 4 Class 5 Class 6 Class 7 Class 8 Class 9 Class 10 78 81 96 85 88 78 90 79 96 86 77 78 97 90 88 82 86 93 87 89 78 93 88...

  • A statistics instructor recorded the grades of his students on the final exam. The grades are:

    A statistics instructor recorded the grades of his students on the final exam. The grades are: 65, 72, 85, 92, 60, 52, 75, 79, 80, 89, 50, 59, 95, 99, 89, 77, 62, 65, 67, 73, 85, 23, 89, 94, 97 a. Construct a stem-and-leaf display. b. Describe the shape of the distribution. c. Deterinine the mode and median of these scores. d. What percentage of the students passed (at least a 70).

  • Midterm1 = (83.33, 98.33, 75, 91.67, 96.67, 95, 86.67, 65, 100, 100, 80, 88.33, 96.67, 96.67,...

    Midterm1 = (83.33, 98.33, 75, 91.67, 96.67, 95, 86.67, 65, 100, 100, 80, 88.33, 96.67, 96.67, 90, 96.67, 86.67, 93.33, 80, 91.67, 98.33, 86.67, 85, 86.67, 95, 83.33, 96.67, 81.67, 98.33, 100, 95, 93.33, 91.67, 88.33, 98.33, 93.33, 98.33, 93.33, 85, 88.33, 100, 98.33, 96.67, 90, 86.67, 100, 96.67, 98.33, 90, 96.67, 86.67, 95, 78.33, 86.67, 100, 81.67, 96.67, 91.67, 96.67, 96.67, 95, 96.67, 73.33, 100, 93.33, 96.67, 88.33, 70, 96.67, 96.67, 100, 88.33, 96.67, 100, 88.33, 100, 78.33, 93.33,...

  • Please help me with this program.You are to write a C++ program that will read in...

    Please help me with this program.You are to write a C++ program that will read in up to 15 students with student information and grades. Your program will compute an average and print out certain reports. Format: The information for each student is on separate lines of input. The first data will be the student�s ID number, next line is the students name, next the students classification, and the last line are the 10 grades where the last grade is...

  • Professor Dolittle has asked some computer science students to write a program that will help him...

    Professor Dolittle has asked some computer science students to write a program that will help him calculate his final grades. Professor Dolittle gives two midterms and a final exam. Each of these is worth 100 points. In addition, he gives a number of homework assignments during the semester. Each homework assignment is worth 100 points. At the end of the semester, Professor Dolittle wants to calculate the median score on the homework assignments for the semester. He believes that the...

  • Using C#: • Create a "Grades" class with the private variables: double grade1, double grade2, double...

    Using C#: • Create a "Grades" class with the private variables: double grade1, double grade2, double grade3, double grade4, double grade5. • In the Main method, ask the user to enter the five grades. • In the ToString() method of the Grades class, print out the mean average (Example: Average: 86). • Also, in the ToString() method of the Grades class, print out the 5 grades that were entered from highest to lowest. For example, if the user entered: 100,...

  • Student stress at final exam time comes partly from the uncertainty of grades and the consequence...

    Student stress at final exam time comes partly from the uncertainty of grades and the consequences of those grades. Can knowledge of a midterm grade be used to predict a final exam grade? A random sample of 200 BCOM students from recent years was taken and their percentage grades on assignments, midterm exam, and final exam were recorded. Let’s examine the ability of midterm and assignment grades to predict final exam grades. The data are shown here: Assignment Midterm FinalExam...

  • An article of the American Journal of Clinical Pathology, by Metz et al. (A-4) published the...

    An article of the American Journal of Clinical Pathology, by Metz et al. (A-4) published the comparison of three methods to determine the percentage of dysmorphic erythrocytes in the urine. They obtained the following results when using the A (X) and B (Y) methods in 75 urine samples. Draw a scatter diagram and obtain the regression equation and graph it on the diagram. X            Y            X            Y            X            Y            X            Y 0            0            20          16          65          55          89          81 0           ...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT