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

having trouble getting the correct results and i dont understand why? #include <

ID: 3687040 • Letter: H

Question

having trouble getting the correct results and i dont understand why?

#include <iostream>
using namespace std;

bool figureGrade(int score, char &grade);

int main()
{
   int score;
   char grade;
   for (int i = 0; i < 7; i++)
   {
       cout << "Input the score of the student : " << endl;
       cin >> score;
       if (figureGrade(score, grade))
       {
           cout << "score assigned is " << score << endl << "Grade assigned is " << grade << endl;
       }
       else
       {
           cout << "No grade is assigned";
       }
   }
   return 0;
}
bool figureGrade(int score, char &grade)

{
   if (score>100 || score<0)
       return false;

   else
       if (score >= 90)
       {
           grade = 'A';
       }
       else if (grade >= 80)
       {
           grade = 'B';
       }
       else if (grade >= 70)
       {
           grade = 'C';
       }
       else if (grade >= 60)
       {
           grade = 'D';
       }
       else
       {
           grade = 'F';
       }
   return true;
}
/*
having problem with the results and dont understand why


Input the score of the student :
55
score assigned is 55
Grade assigned is F
Input the score of the student :
65
score assigned is 65
Grade assigned is C
Input the score of the student :
75
score assigned is 75
Grade assigned is D
Input the score of the student :
85
score assigned is 85
Grade assigned is D
Input the score of the student :
95
score assigned is 95
Grade assigned is A
Input the score of the student :


*/

Explanation / Answer

Hi I have fixed your issue. Please test it.

#include <iostream>
using namespace std;

bool figureGrade(int score, char &grade);

int main()
{
   int score;
   char grade;
   for (int i = 0; i < 7; i++)
   {
       cout << "Input the score of the student : " << endl;
       cin >> score;
       if (figureGrade(score, grade))
       {
           cout << "score assigned is " << score << endl << "Grade assigned is " << grade << endl;
       }
       else
       {
           cout << "No grade is assigned";
       }
   }
   return 0;
}
bool figureGrade(int score, char &grade)

{
       if (score>100 || score<0)
           return false;

       if (score >= 90)
       {
           grade = 'A';
       }
       else if (score >= 80)
       {
           grade = 'B';
       }
       else if (score >= 70)
       {
           grade = 'C';
       }
       else if (score >= 60)
       {
           grade = 'D';
       }
       else
       {
           grade = 'F';
       }
   return true;
}