Have the following data...
A 450 - 500 points
B 400 - 449 points
C 350 - 399 points
D 300 - 349 points
F 0 - 299 points
were the letters a,b,c,d,f are the grades needed to be output.
Must also be a paraellel array
I wrote the following using the text, but all I get is F for the letter grade. Any insight would help
Thanks in advance
A 450 - 500 points
B 400 - 449 points
C 350 - 399 points
D 300 - 349 points
F 0 - 299 points
were the letters a,b,c,d,f are the grades needed to be output.
Must also be a paraellel array
I wrote the following using the text, but all I get is F for the letter grade. Any insight would help
Thanks in advance
Code:
#include <iostream>
#include <string>
#include <algorithm>
using std::cout;
using std::cin;
using std::endl;
using std::string;
int main()
{
//declare variables and arrays
string searchForTotalPoints = "";
int minPoints[5] = {0, 300, 350, 400, 450};
string grades[5] = {"F", "D", "C", "B", "A"};
// Get Grade to search for
cout << "Enter Total Points(Z to Exit): ";
getline(cin, searchForTotalPoints);
while (searchForTotalPoints != "X")
{
//locate position of the totalpoints in the minPoints array
int y = 0;
//keeps track of array subscripts
while (y < 5 && grades[y] <= searchForTotalPoints)
y = y + 1;
//end while
// if totalPoints found, display grade from grades array
// otherwise display error message
if (y < 5)
cout << "Total Points: " << grades[y] << endl;
else
cout << "Total Points are not valid." << endl;
//end if
//Get totalPoints to search for
cout << "Enter Total Points (Z to exit): ";
getline(cin, searchForTotalPoints);
} //end while
return 0;
} //end of main function
Comment