#include <iostream>
usingnamespace std;
int main()
{
string answer; // char is a single like 'Y' or 'N'
int income, financial_aid;
cout << "Are you an undergraduate student?";
cin >> answer;
if (answer == "Yes")// char is a single like 'Y' strings are like "Yes"
{
cout << "What is your yearly income?";
cin >> income;
if (income <= 15000)
{
cout << "You qualify for $1000 in financial aid. ";
}
elseif (income > 15000)
{
cout << "You qualify for $500 in financial aid. ";
}
}
// else // you don't need anything after the else here.
// If you do then use this
elseif (answer == "No") // char is a single like 'Y' strings are like "No"
{
cout << "You do not qualify for financial aid. ";
}
system("pause"); // Used to display output box
return 0;
}
A C-string, which consists of an array of characters terminated by the null character '\0', and which therefore is different from an ordinary array of characters. There is a whole library of functions for dealing with strings represented in this form. Its header file is <cstring>. In some implementations this library may be automatically included when you include other libraries such as the <iostream> library.