Hey everyone :) I'm writing a program for my class that has the user input 5 test scores and then from the inputted numbers, return the letter grade. I've begun writing the LetterGrade function, but it's not working. I'm getting a strange array of numbers/letters instead of the actual letter grade. If someone could look it over, i'd appreciate it. Thanks.
#include <iostream>
#include <conio.h>
#include <iomanip>
using namespace std;
float GetTestScore();
char LetterGrade(double numbergrade);
int main()
{
float test1, test2, test3, test4, test5;
cout << "What is the score for test 1? ";
test1 = GetTestScore();
cout << "What is the score for test 2? ";
test2 = GetTestScore();
cout << "What is the score for test 3? ";
test3 = GetTestScore();
cout << "What is the score for test 4? ";
test4 = GetTestScore();
cout << "What is the score for test 5? ";
test5 = GetTestScore();
cout << endl;
cout << "Test 1 " << endl;
cout << test1 << endl;
cout << LetterGrade << endl;
cout << "Test 2 " << endl;
cout << test2 << endl;
cout << LetterGrade << endl;
cout << "Test 3 " << endl;
cout << test3 << endl;
cout << LetterGrade << endl;
cout << "Test 4 " << endl;
cout << test4 << endl;
cout << LetterGrade << endl;
cout << "Test 5 " << endl;
cout << test5 << endl;
cout << LetterGrade << endl;
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(1);
getch();
return 0;
}
float GetTestScore()
{
float TestScore;
cin >> TestScore;
while (TestScore < 0 || TestScore > 100)
{
cout << "Please enter a test score between 0 and 100. " <<endl;
cin >> TestScore;
}
return TestScore;
}
char LetterGrade(double numbergrade)
{
char LetterGrade;
{
if (numbergrade <= 100 || numbergrade >= 90)
cout << "A";
if (numbergrade <= 89 || numbergrade >= 80)
cout << "B";
if (numbergrade <= 79 || numbergrade >= 70)
cout << "C";
if (numbergrade <= 69 || numbergrade >= 60)
cout << "D";
if (numbergrade <= 59 || numbergrade >= 50)
cout << "F";
}
return LetterGrade;
}