Hi guys I'm new to C++ in college and am struggling with some codes. Here is one that has me stumped. It is supposed to prompt the user for 5 numbers and output the average of the numbers and assign a letter grade to it. Keep in mind I am really new(this is my third code) and would appreciate it being kept simple and an explanation. Thanks so much!
//This program will prompt the user for 5 numbers and output the average of these numbers
//and a letter grade
//Prompt for 5 numbers and your name
cout << "Please input your name\n" << endl;
cin >> name;
cout << "Okay "<< name <<" please input five numbers";
cin >> num1;
cin >> num2;
cin >> num3;
cin >> num4;
cin >> num5;
//Calculate the average
//Determine letter grade based on average
letter = ('A');
letter = ('B');
letter = ('C');
letter = ('D');
letter = ('F');
else cout << "There is an error";
1) Your if/else-if statements shouldn't have a ; at the end.
2) Your reading a name into a double, it should be a string
3) The avg<60 code should either be else-if or else without the avg<60, resulting in a F grade.
4) You need to print the grade at the end.
This whole process would be a bit simpler with arrays but I'm not sure you'll have covered them yet.
Yeah I'm sorry I only have access to the program that runs the code while I am in class so I kinda forget where things went wrong, but I remember my first problem I think started somewhere on line 25 or near there I couldnt get the program to read back my name after I typed it in. Also I have no idea what an array is sorry :P