My new assignment is to write a program to get a users name, have them input ten grade (int, number format), then convert those to letter grade format, and return all numeric and letter grades back to the user with an average as well. I wrote a
test program to see if the first int and
string would work before writing the entire code, but this is my first does of nested if statements, and I know there has to be a more efficient way to do this other than how I've built it. Can anyone tell me what I did wrong here and what the best practice is for such a program?
<code>#include "stdafx.h"
#include <iostream>
#include <string>
using namespace std;
int main (){
int grade1, grade2, grade3, grade4, grade5, grade6, grade7, grade8, grade9, grade10;
string username, letter1, letter2, letter3, letter4, letter5, letter6, letter7, letter8, letter9, letter10;
cout << "What is your user name? " << endl;
cin >> username;
cout << "What are the ten grades you received this semester?" << endl;
cin >> grade1;
cin >> grade2;
cin >> grade3;
cin >> grade4;
cin >> grade5;
cin >> grade6;
cin >> grade7;
cin >> grade8;
cin >> grade9;
cin >> grade10;
if ( 69 < grade1 <= 79)
letter1 = C;
if ( 79 < grade1 <= 89)
letter1 = B;
if ( 89 < grade1)
letter1 = A;
cout << " Grade = " << grade1 << " = " << letter 1 << endl;
return 0;
}
</code>