hey guys i need help with my code. i need help with yes or no question.
here is my code. what i need help is only 'y' or 'n' should work. when i enter 'y' than it will continue ask question but when i enter 'n' it will display You do not qualify for financial aid. so let say when i enter 'h' than it should give me an error.
#include <iostream>
usingnamespace std;
int main()
{
int currentIncome;
char underGraduate;
cout << "Are you an undergraduate student?";
cin >> underGraduate;
if (underGraduate == 'y')
{
cout << "What is your current yearly income?";
cin >> currentIncome;
if (currentIncome < 0)
{
cout << "Income must be greater than or equal to 0!\n";
}
elseif (currentIncome <= 15000)
{
cout << "You qualify for $1000 in financial aid.\n";
}
elseif (currentIncome > 15000)
{
cout << "You qualify for $500 in fiancial aid.\n";
}
}
else
{
cout << "You do not qualify for financial aid\n";
}
system("pause");
return 0;
}
#include <iostream>
usingnamespace std;
int main()
{
int currentIncome;
char underGraduate;
cout << "Are you an undergraduate student?";
cin >> underGraduate;
if (underGraduate == 'y' || underGraduate == 'n')
{
if (underGraduate == 'y')
{
cout << "What is your current yearly income?";
cin >> currentIncome;
if (currentIncome < 0)
{
cout << "Income must be greater than or equal to 0!\n";
}
elseif (currentIncome <= 15000)
{
cout << "You qualify for $1000 in financial aid.\n";
}
elseif (currentIncome > 15000)
{
cout << "You qualify for $500 in fiancial aid.\n";
}
}
elseif (underGraduate == 'n')
{
cout << "You do not qualify for financial aid\n";
}
}
else
{
cout << "Please enter y or n only!\n";
}
system("pause");
return 0;
}