#include <cstdlib>
#include <iostream>
#include <cmath>
#include <string>
usingnamespace std;
int main(int argc, char *argv[])
{
float test, quiz, home, grade;
int choice;
cout << "Welcome to the tutorial program. What would you like to know?\n\n";
cout << " 1. What is my current grade?\n";
cout << " 2. Info about the program.\n\n";
cout << "Please enter your choice: ";
cin >> choice;
cout << "\n\n\n\n";
if(choice == 1)
cout << "You have chosen program number one.\n\n";
cout << "Please enter your average test score: ";
cin >> test;
cout << "\nPlease enter your average quiz score: ";
cin >> quiz;
cout << "\nPlease enter your average homework score: ";
cin >> home;
grade = (test * .5) + (quiz * .4) + (home * .1)/3;
cout << "\n\nYour current grade is: " << grade << "%";
elseif(choice == 2)
cout << "This program was created by Mitchell DeJonghe.\n";
cout << "Created using Dev-C++ 4.9.9.2.\n";
cout << "Date Created :10/24/11\n";
cout << "Date Updated: 10/24/11\n\n";
else(choice > 2)
cout << "Invalid choice";
system("PAUSE");
return EXIT_SUCCESS;
}
I'm getting the "expected primary-expression before else" error on lines 35 and 41. Whats the problem?
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <string>
usingnamespace std;
int main(int argc, char *argv[])
{
float test, quiz, home, grade;
int choice;
cout << "Welcome to the tutorial program. What would you like to know?\n\n";
cout << " 1. What is my current grade?\n";
cout << " 2. Info about the program.\n\n";
cout << "Please enter your choice: ";
cin >> choice;
cout << "\n\n\n\n";
if(choice == 1)
{
cout << "You have chosen program number one.\n\n";
cout << "Please enter your average test score: ";
cin >> test;
cout << "\nPlease enter your average quiz score: ";
cin >> quiz;
cout << "\nPlease enter your average homework score: ";
cin >> home;
grade = (test * .5) + (quiz * .4) + (home * .1)/3;
cout << "\n\nYour current grade is: " << grade << "%";
}
elseif(choice == 2)
{
cout << "This program was created by Mitchell DeJonghe.\n";
cout << "Created using Dev-C++ 4.9.9.2.\n";
cout << "Date Created :10/24/11\n";
cout << "Date Updated: 10/24/11\n\n";
}
else // (choice > 2) not required... and not right...
{
cout << "Invalid choice";
}
system("PAUSE");
return EXIT_SUCCESS;
}