In: Computer Science
I have a error code, for my C++ class, using Putty
include <iostream>
using namespace std;
int main()
{
char answer;
char grade;
cout << "Are you taking a class (enter y, Y, N or N): "
<< endl;
cin >> answer;
if (answer == 'N' || 'n');
{
cout << "Thanks for using the system" << endl;
}
else if (answer == 'Y' || 'y');
{
cout << "Enter a letter grade (A, B, C, D, or F): " <<
endl;
cin >> grade;
switch(grade);
{
case 'A':
cout << "Great Job!" << endl;
break;
case 'B':
cout << "Great Job!" << endl;
break;
case 'C':
cout << "You're doing alright." << endl;
break;
case 'D':
cout << "You can improve." << endl;
break;
case 'F':
cout << "You can improve." << endl;
break;
default:
cout << "Invalid grade." << endl;
break;
}
}
else
{
cout << "Invalid input" << endl;
}
return 0;
}
#include <iostream> using namespace std; int main() { char answer; char grade; cout << "Are you taking a class (enter y, Y, N or N): " << endl; cin >> answer; if (answer == 'N' || answer == 'n') { cout << "Thanks for using the system" << endl; } else if (answer == 'Y' || answer == 'y') { cout << "Enter a letter grade (A, B, C, D, or F): " << endl; cin >> grade; switch (grade) { case 'A': cout << "Great Job!" << endl; break; case 'B': cout << "Great Job!" << endl; break; case 'C': cout << "You're doing alright." << endl; break; case 'D': cout << "You can improve." << endl; break; case 'F': cout << "You can improve." << endl; break; default: cout << "Invalid grade." << endl; break; } } else { cout << "Invalid input" << endl; } return 0; }