hey guys my program assigns a letter grade to a specfic percentage for an exam score and the problem is taht if i enter a number that is not specified in my if statements it should say invalid number but the program juss prints out the regular output with no letter grade instead any help would be very appreciated ty
#include <iostream>
#include <string>
using namespace std;
void GetScore(double&);
bool IsValid(double&);
string LetterGrade(double&);
void Display(double&, string&, bool&);
int main()
{
double exam_score;
bool check;
string letter_grade;
GetScore(exam_score);
check = IsValid(exam_score);
letter_grade = LetterGrade(exam_score);
Display(exam_score, letter_grade, check);
cout<<"Written By Ravi Mandair CPSC 1103 Section 10"<<endl;
return 0;
}
void GetScore(double& get_data)
{
cout<<"Please enter your exam score as a percentage\n"
<<"but without the actual % sign: ";
cin>>get_data;
return;
}
bool IsValid (double& data)
{
bool check_data;
if ((data >= 0) && (data <= 100))
check_data = true;
else
check_data = false;
return check_data;
}
string LetterGrade(double& exam_percentage)
{
string assign_grade;
if (exam_percentage >= 80 && exam_percentage <= 100)
assign_grade = 'A';
if (exam_percentage >= 60 && exam_percentage <= 79)
assign_grade = 'B';
if (exam_percentage >= 50 && exam_percentage <= 59)
assign_grade = 'A';
if (exam_percentage <= 49)
assign_grade = 'F';
return assign_grade;
}
void Display(double& exam_score, string& letter_grade, bool& check)
{
if (check = true)
cout<<"You recieved a score of "<<exam_score<<" which\n"
<<"is equivalent to the letter grade "<<letter_grade<<endl;
else
cout<<"You entered a score of "<<exam_score<<endl
<<" ,invalid mark is out of range";
return;
}