Hi, the name's Keyaki and, like the title says, I'm new here. And I need help with a tiny problem. And by "tiny", I mean its an issue that I should know how to solve myself but unfortunately, I'm at a loss.
I scoured the forums for answers but I couldn't find anything, 'tis why I'm posting here.
Here's the issue. I'm writing a simple program that takes a person's name and 5 recent tests grades and averages them using a module and a function and if-else-if statements.
The problem is the IDE I'm using, Visual Studio '10, is giving me an error message under the '<' operators in the if-else-if statements in the Grade module.
The error messages are simply state: "Expected an expression".
I've checked the rest of the code and everything checks out and I've done if-else-if statements in code before and I don't recall encountering any error like this.
Can anyone tell me, exactly what I'm doing wrong? Thanks.
Code:
#include<iostream>
#include <string>
using namespace std;
double calcAverage(double grade1, double grade2, double grade3, double grade4, double grade5);
void Grade(double average);
int main()
{
char grade;
char confirm;
string firstName;
string lastName;
string name;
double grade1;
double grade2;
double grade3;
double grade4;
double grade5;
double average;
cout << "What's your name?" << endl;
getline(cin,name);
cout << name << " ? Is that your name? Yes(y) or No(n)" << endl;
cin >> confirm;
while(confirm == 'n')
{
cout << "Then what is your first and last name?" << endl;
cin >> firstName;
cin >> lastName;
cout << firstName <<" "<< lastName << ", Is that your name? Yes(Y) or No(N)" << endl;
cin >> confirm;
}
cout << "Enter your 5 most recent test grades." << endl;
cin >> grade1;
cin >> grade2;
cin >> grade3;
cin >> grade4;
cin >> grade5;
average= calcAverage(grade1, grade2, grade3, grade4, grade5);
Grade(average);
cout << "Press any button to close. " << endl;
cin.ignore().get();
return 0;
}
double calcAverage(double grade1, double grade2, double grade3, double grade4, double grade5)
{
double averageResult;
averageResult=grade1+grade2+grade3+grade4+grade5/5;
return averageResult;
}
void Grade(double average)
{
if(average >= 100)
{
cout << "A+!" << endl;
}
else if(average >= 90 && < 100)
{
cout << "A!" << endl;
}
else if(average >= 80 && < 90)
{
cout << "B!" << endl;
}
else if(average >= 70 && < 80)
{
cout << "C!" << endl;
}
else if(average >= 60 && < 70)
{
cout << "D!" << endl;
}
else
{
cout << " F..." << endl;
}
}