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

Sample Input : Please enter the name of the exam: ? Biology Exam 1 Enter score 1

ID: 3811014 • Letter: S

Question

Sample Input:

Please enter the name of the exam: ? Biology Exam 1

Enter score 1: ? 89

Enter score 2: ? 99

Enter score 3: ? 65

Enter score 4: ? 54

Enter score 5: ? 48

Enter score 6: ? 78

Enter score 7: ? 66

Enter score 8: ? 56

Enter score 9: ? 86

Enter score 10: ? 74

Enter score 11: ? 92

Enter score 12: ? 88


Sample Output:

The scores for Biology Exam 1 are:

89 99 65 54 48 78 66 56 86 74 92 88

The average score is 74.58

The highest score is 99

The lowest score is 48

Number of Students who passed: 9

Number of Students who failed: 3

The number of exams represented by each letter grade is as follows:

A's: 2

B's: 3

C's: 2

D's: 2

F's: 3

Would you like to calculate the average for another exam? <Y or N> y

Sample Input:

Please enter the name of the exam: ? Latin Exam 2

Enter score 1: ? 88

Enter score 2: ? 100

Enter score 3: ? 56

Enter score 4: ? 78

Enter score 5: ? 65

Enter score 6: ? 45

Enter score 7: ? 80

Enter score 8: ? 95

Enter score 9: ? 92

Enter score 10: ? 85

Enter score 11: ? 75

Enter score 12: ? 79

Sample Output:

The scores for Latin Exam 2 are:

88 100 56 78 65 45 80 95 92 85 75 79

The average score is 78.17

The highest score is 100

The lowest score is 45

Number of Students who passed: 10

Number of Students who failed: 2

The number of exams represented by each letter grade is as follows:

A's: 3

B's: 3

C's: 3

D's: 1

F's: 2

Would you like to calculate the average for another exam? <Y or N> n

Explanation / Answer

PROGRAM CODE:

/*
* MarksOfStudents.cpp
*
* Created on: 05-Apr-2017
* Author: kasturi
*/

#include <iostream>
#include <iomanip>
using namespace std;

void getData(string &name, int marks[])
{
   cout << "Please enter the name of the exam: ?" << endl;
   cin>>name;

for (int i = 0 ; i < 12 ; i++)
{
cout<<"Enter score "<<(i+1)<<": ?";
   cin>>marks[i];
}

}
void getAverageMark(int marks[], float &avg)
{
avg = 0.0;
for (int i = 0; i < 12; i++)
{
avg += marks[i];
}
avg = avg / 12;

}
void getLowestMark(int marks[], int &smallest)
{
smallest = marks[0] ;
for ( int i = 0; i < 12; ++i )
if ( marks[i] < smallest )
smallest = marks[i] ;

}
void getHighestMark(int marks[], int &highest)
{
highest = marks[0] ;
for ( int i = 0; i < 12; ++i )
if ( marks[i] > highest )
highest = marks[i] ;
}

void passAndFail(int marks[], int &passCount, int &failCount)
{

   for ( int i = 0; i < 12; ++i )
   {
       if(marks[i]<60)
           failCount++;
       else
           passCount++;
   }

}

void gradeCount(int marks[], int &a, int &b, int &c, int &d, int &f)
{

   for ( int i = 0; i < 12; ++i )
       {
           if(marks[i]<60)
               f++;
           else if(marks[i]>=60 && marks[i]<70)
               d++;
           else if(marks[i]>=70 && marks[i]<80)
               c++;
           else if(marks[i]>=80 && marks[i]<90)
               b++;
           else if(marks[i]>=90 && marks[i]<=100)
               a++;
       }

}

void process()
{
   char continueDoing = 'Y';
   int marks[12], highestMark, lowestMark;
   int a = 0, b = 0, c = 0, d = 0, f = 0;
   int passCount = 0, failCount = 0;
   float avg = 0;
   string name = "";
   while(continueDoing == 'Y')
   {
       getData(name, marks);
       getAverageMark(marks, avg);
       getHighestMark(marks, highestMark);
       getLowestMark(marks, lowestMark);
       passAndFail(marks, passCount, failCount);
       gradeCount(marks, a, b, c, d, f);

       cout<<" The scores for "<<name<<" are: ";
       for(int i=0; i<12; i++)
           cout<<marks[i]<<" ";
   cout<<fixed<<setprecision(2)<<" The average score is "<<avg<<endl;
   cout<<"The highest score is "<<highestMark<<endl;
       cout<<"The lowest score is "<<lowestMark<<endl;
       cout<<"Number of Students who passed: "<<passCount<<endl;
       cout<<"Number of Students who failed: "<<failCount<<endl;
       cout<<"The number of exams represented by each letter grade is as follows: ";
       cout<<"A's: "<<a<<endl;
       cout<<"B's: "<<b<<endl;
       cout<<"C's: "<<c<<endl;
       cout<<"D's: "<<d<<endl;
       cout<<"F's: "<<f<<endl;
       cout<<"Would you like to calculate the average for another exam? <Y or N> ";
       cin>>continueDoing;
       cout<<endl;
   }

}

int main()
{
   process();
   return 0;
}

OUTPUT:

Please enter the name of the exam: ?

Biology

Enter score 1: ?65

Enter score 2: ?78

Enter score 3: ?98

Enter score 4: ?56

Enter score 5: ?76

Enter score 6: ?45

Enter score 7: ?53

Enter score 8: ?99

Enter score 9: ?87

Enter score 10: ?52

Enter score 11: ?71

Enter score 12: ?83


The scores for Biology are:

65 78 98 56 76 45 53 99 87 52 71 83

The average score is 71.92

The highest score is 99

The lowest score is 45

Number of Students who passed: 8

Number of Students who failed: 4

The number of exams represented by each letter grade is as follows:

A's: 2

B's: 2

C's: 3

D's: 1

F's: 4

Would you like to calculate the average for another exam? <Y or N> n

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