PLEASE PAY CLOSE ATTENTION TO YOUR ANSWER WHAT I WROTE IN MY

PLEASE, PAY CLOSE ATTENTION TO YOUR ANSWER, WHAT I WROTE IN MY EXPLANATION OF THE PROBLEM THAT I THINK MY CODE HAS AND THE SAMPLE RUN PROVIDED FOR THE ASSIGNMENT. EVERY WORD I WROTE IS MEANINGFUL AND I POSTED THIS QUESTION ALREADY 4 TIMES. SO, PLEASE DON\'t RUSH TO ANSWER.

Write a C++ program to obtain the Mid_term and Final exam scores for 10 students (Student 1 to Student 10) from the user and then compute and print the following:

1 Total score, where Total score = 40% (Mid_term) + 60%(Final).

2 Maximum score in Mid-Term exam and the corresponding student

3 Maximum score in Final exam and the corresponding student

Requirements:

1 .You have to use ARRAYS

2 .You are required to use user-defined functions for the following tasks:

a . Getting the Mid-term and Final exam scores from the user

b . Calculating the Total score

c . Computing the maximum scores in Mid-term and Final exam.

3 .Assume it’s a maximum of 10 students and all of them have scores >=0 but <=100. You are therefore, required to make sure the user’s input falls in the valid range. If not, give him/her one more chance to enter the right score.

4 .If the user does not enter the right score, after two chances, set the score to ZERO and move to the next score.

5 .Make sure you scan the user’s input as described above for one student, before going to the next.

Hint: Use one array each to store Mid-term and Final scores.

Sample RUN:

Please enter the Mid-term and Final scores for student 1

20

98.5

Please enter the Mid-term and Final scores for student 2

-10.9 35

Sorry, the scores have to be in the range of 0 to 100. Please enter the Mid-Term score again:

90

Please enter the Mid-Term and Final scores for Student 3

90

120

Sorry, the scores have to be in the range of 0 to 100. Please enter the Final Exam score again: 99

Please enter the Mid-Term and Final scores for Student 7

101 -20

Sorry, the scores have to be in the range of 0 to 100. Please enter the scores again: 999

-10

//After giving one more chance, if the user’s input is invalid, set the Mid-term and Final exam scores to 0 and move to the next student.

Please enter the Mid-Term and Final scores for Student 10

90

100

Thank you!

Here is the total score for all the students in your class.

Student 1

67.1

Student 2

57

Student 3

               

95.4

Student 7

0.0

Student 10

96

Maximum score in Mid-term exam is 99 and was scored by Student 4

Maximum score in Final exam is 100 and was scored by Student 10

THIS IS what I GOT SO FAR, but still, the final output is not printing out the correct total of the student; I think because the values of the MidTerm[i] and FinalExam[i] don\'t get updated after finishing the maximum number of trials to re-enter the values of the midterm and final exam scores.

One last thing..... I have 3 CHECK stages in the body of my main:(( IT HAS TO BE THIS WAY ACCORDING TO THE SAMPLE RUN THE THREE INSTANCES HAVE DIFFERENT COUTs )):

1. if both the midterm && final exam score are entered wrong

2. if midterm exam score ONLY is entered wrong by the user

3. if Final exam score ONLY is entered wrongly by the user.

CODE

------------------------------------------------------------

#include

using namespace std;

//Function that calculates total score
void calculateTotalScore(double MidTerm[], double FinalExam[])
{
int i;
double total;

cout << \"\ \ Total Score of all students in the class: \ \";

//Iterating over scores
for(i=0; i<10; i++)
{
//Calculating total score as Total = 40% (Mid_term) + 60%(Final)
total = ( (40/100.0) * (MidTerm[i]) ) + ( (60/100.0) * (FinalExam[i]) );

//Printing result
cout << \"\ Student \" << (i+1) << \" : \" << total;
}

cout << \"\ \ \";
}

//Function that finds the maximum mid term score
void findMaxMidTermScore(double MidTerm[])
{
int i, max=0;

//Iterating over midterm scores
for(i=0; i<10; i++)
{
//Updating max score index
if(MidTerm[i] > MidTerm[max])
max = i;
}

//Printing max mid term score details
cout << \"\ \ Maximum score in Mid-term exam is \" << MidTerm[max] << \" and was scored by Student \" << (max+1) << \" \ \ \";
}


//Function that finds the maximum Final exam score
void findFinalExamScore(double FinalExam[])
{
int i, max=0;

//Iterating over final exam scores
for(i=0; i<10; i++)
{
//Updating max score index
if(FinalExam[i] > FinalExam[max])
max = i;
}

//Printing max final exam score details
cout << \"\ \ Maximum score in Mid-term exam is \" << FinalExam[max] << \" and was scored by Student \" << (max+1) << \" \ \ \";
}

//Main function
int main()
{
double MidTerm[10], FinalExam[10];
double mid=0, finalScore=0;
int i, k, z, y;

//Iterating over 10 students
for(i=0; i<10; i++)
{
//Reading scores
cout << \"\ \ Please enter the Mid-term and Final scores for student \" << (i+1) << \": \ \";
cin >> mid >> finalScore;

//validating both midterm and finalscores
k=0;
if ( ( (mid < 0 || mid >100) && (finalScore < 0 || finalScore > 100) ) && k<=1 ) {
  
cout << \"\ Sorry, the scores have to be in the range of 0 to 100. Please enter both midterm and Final Exam scores again\" << endl;
cin >> mid >>finalScore;

k++;

cout << \"The value of K in the if loop is =\" << k < }

else if (k > 1)
{

MidTerm[i]=0;
FinalExam[i]=0;
mid = 0;
finalScore = 0;

}

//Validating mid term score
z=0;
if( (mid < 0 || mid > 100) && z <= 1 && k!=1 )
{
cout << \"\ Sorry, the scores have to be in the range of 0 to 100. Please enter the Mid-Term score again: \";
cin >> mid;

z++;
}

//Assigning value to mid term score
else if(z>1)
{
MidTerm[i] = 0;

}
else
{
MidTerm[i] = mid;
}

//Validating final exam score

y=0;
if( (finalScore < 0||finalScore > 100) && y <= 1 && k!=1)
{
cout << \"\ Sorry, the scores have to be in the range of 0 to 100. Please enter the Final Exam score again: \";
cin >> finalScore;

y++;
}

//Updating final exam score details
else if(y>1)
{
FinalExam[i] = 0;
}
else
{
FinalExam[i] = finalScore;

}//end of else
}//end of for loop that iterates over the 10 students


//Calculating total scores
calculateTotalScore(MidTerm, FinalExam);

//Finding maximum midterm score
findMaxMidTermScore(MidTerm);

//Finding maximum final exam score
findFinalExamScore(FinalExam);

cout << \"\ \ \";
return 0;
}

Student 1

67.1

Student 2

57

Student 3

               

95.4

Student 7

0.0

Student 10

96

Solution

I have changes some code of yours as there was some logical error in the program .. You can search for the lines changed or added by key word \"chegg EA\"

---------------------------------------------------------------------------

#include<iostream>

using namespace std;
//Function that calculates total score
void calculateTotalScore(double MidTerm[], double FinalExam[])
{
int i;
double total;
cout << \"\ \ Total Score of all students in the class: \ \";
//Iterating over scores
for(i=0; i<10; i++)
{
//Calculating total score as Total = 40% (Mid_term) + 60%(Final)
total = ( (40/100.0) * (MidTerm[i]) ) + ( (60/100.0) * (FinalExam[i]) );
//Printing result
//added by chegg EA
if( total > 0 )
cout << \"\ Student \" << (i+1) << \" : \" << total;
}
cout << \"\ \ \";
}
//Function that finds the maximum mid term score
void findMaxMidTermScore(double MidTerm[])
{
int i, max=0;
//Iterating over midterm scores
for(i=0; i<10; i++)
{
//Updating max score index
if(MidTerm[i] > MidTerm[max])
max = i;
}
//Printing max mid term score details
cout << \"\ \ Maximum score in Mid-term exam is \" << MidTerm[max] << \" and was scored by Student \" << (max+1) << \" \ \ \";
}

//Function that finds the maximum Final exam score
void findFinalExamScore(double FinalExam[])
{
   int i, max=0;
   //Iterating over final exam scores
   for(i=0; i<10; i++)
   {
   //Updating max score index
   if(FinalExam[i] > FinalExam[max])
   max = i;
   }
   //Printing max final exam score details
   //changed by chegg EA from Mid-term to final exam
   cout << \"\ \ Maximum score in Final exam exam is \" << FinalExam[max] << \" and was scored by Student \" << (max+1) << \" \ \ \";
}
//Main function
int main()
{
   //added this line by chegg EA,initialize arrays with zero
   double MidTerm[10]={0}, FinalExam[10]={0};
   double mid=0, finalScore=0;
   int i, k, z, y;
//Iterating over 10 students
   for(i=0; i<10; i++)
   {
       //Reading scores
       cout << \"\ \ Please enter the Mid-term and Final scores for student \" << (i+1) << \": \ \";
       cin >> mid >> finalScore;
       //validating both midterm and finalscores
       k=0;
if ( ( (mid < 0 || mid >100) && (finalScore < 0 || finalScore > 100) ) && k<=1 )
       {
           cout << \"\ Sorry, the scores have to be in the range of 0 to 100. Please enter both midterm and Final Exam scores again\" << endl;
           cin >> mid >>finalScore;
           k++;
           cout << \"The value of K in the if loop is =\" << k ;
           //added this line by chegg EA
           if( ( (mid < 0 || mid >100) && (finalScore < 0 || finalScore > 100) ) )
           {
               k++;
           }
       }
       //changed else if by chegg EA
       if (k > 1)
       {
           MidTerm[i]=0;
           FinalExam[i]=0;
           mid = 0;
           finalScore = 0;
       }
       //added this line by chegg EA
       else
       {
           MidTerm[i]=mid;
           FinalExam[i]=finalScore;
       }
       //Validating mid term score
       z=0;
       if( (mid < 0 || mid > 100) && z <= 1 && k!=1 )
       {
           cout << \"\ Sorry, the scores have to be in the range of 0 to 100. Please enter the Mid-Term score again: \";
           cin >> mid;
           z++;
           //added this line by chegg EA
           if( (mid < 0 || mid > 100) && z <= 1)
               z++;
       }
       //Assigning value to mid term score
       //changed else if by chegg EA
       if(z > 1)
       {
           MidTerm[i] = 0;
       }
       else
       {
           MidTerm[i] = mid;
       }
      
      
      
       //Validating final exam score
       y=0;
       if( (finalScore < 0||finalScore > 100) && y <= 1 && k!=1)
       {
           cout << \"\ Sorry, the scores have to be in the range of 0 to 100. Please enter the Final Exam score again: \";
           cin >> finalScore;
           y++;
           //added this line by chegg EA
           if( (finalScore < 0||finalScore > 100) )
               y++;
       }
       //Updating final exam score details
       //changed else if by chegg EA
       if(y > 1)
       {
           FinalExam[i] = 0;
       }
       else
       {
           FinalExam[i] = finalScore;
       }//end of else
   }//end of for loop that iterates over the 10 students

   //Calculating total scores
   calculateTotalScore(MidTerm, FinalExam);
   //Finding maximum midterm score
   findMaxMidTermScore(MidTerm);
   //Finding maximum final exam score
   findFinalExamScore(FinalExam);
   cout << \"\ \ \";
   return 0;
}

PLEASE, PAY CLOSE ATTENTION TO YOUR ANSWER, WHAT I WROTE IN MY EXPLANATION OF THE PROBLEM THAT I THINK MY CODE HAS AND THE SAMPLE RUN PROVIDED FOR THE ASSIGNMEN
PLEASE, PAY CLOSE ATTENTION TO YOUR ANSWER, WHAT I WROTE IN MY EXPLANATION OF THE PROBLEM THAT I THINK MY CODE HAS AND THE SAMPLE RUN PROVIDED FOR THE ASSIGNMEN
PLEASE, PAY CLOSE ATTENTION TO YOUR ANSWER, WHAT I WROTE IN MY EXPLANATION OF THE PROBLEM THAT I THINK MY CODE HAS AND THE SAMPLE RUN PROVIDED FOR THE ASSIGNMEN
PLEASE, PAY CLOSE ATTENTION TO YOUR ANSWER, WHAT I WROTE IN MY EXPLANATION OF THE PROBLEM THAT I THINK MY CODE HAS AND THE SAMPLE RUN PROVIDED FOR THE ASSIGNMEN
PLEASE, PAY CLOSE ATTENTION TO YOUR ANSWER, WHAT I WROTE IN MY EXPLANATION OF THE PROBLEM THAT I THINK MY CODE HAS AND THE SAMPLE RUN PROVIDED FOR THE ASSIGNMEN
PLEASE, PAY CLOSE ATTENTION TO YOUR ANSWER, WHAT I WROTE IN MY EXPLANATION OF THE PROBLEM THAT I THINK MY CODE HAS AND THE SAMPLE RUN PROVIDED FOR THE ASSIGNMEN
PLEASE, PAY CLOSE ATTENTION TO YOUR ANSWER, WHAT I WROTE IN MY EXPLANATION OF THE PROBLEM THAT I THINK MY CODE HAS AND THE SAMPLE RUN PROVIDED FOR THE ASSIGNMEN
PLEASE, PAY CLOSE ATTENTION TO YOUR ANSWER, WHAT I WROTE IN MY EXPLANATION OF THE PROBLEM THAT I THINK MY CODE HAS AND THE SAMPLE RUN PROVIDED FOR THE ASSIGNMEN

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site