#include "stdafx.h"
#include <iostream>
usingnamespace std;
int _tmain(int argc, _TCHAR* argv[])
{
// Constants for grade thresholds
int A_SCORE = 92,
B_SCORE = 83,
C_SCORE = 75,
F_SCORE = 75;
int testScore;
// Get numeric test score
cout << "Enter your test score to know your letter grade. \n";
cin >> testScore;
while (testScore > 0)
{
// Determine the letter grade.
if (testScore >= A_SCORE)
cout << "Your grade is an A.\n";
elseif (testScore >= B_SCORE)
cout << "Your grade is a B. \n";
elseif (testScore >= C_SCORE)
cout << "Your grade is a C. \n";
elseif (testScore < F_SCORE)
cout << "Your grade is F. \n";
cout << "Enter your test score to know your letter grade. \n";
cin >> testScore;
}
cout << "Invalid test score. \n";
cout << "Please enter a valid test score to know your letter grade. \n";
cin >> testScore;
return 0;
}
Then don't print a newline (\n) before they've entered their score.
1 2 3 4
// Get numeric test score
cout << "Enter your test score to know your letter grade. "; // no \n;
cin >> testScore;
cout << "\n"; // might want one here instead?