Help with a beginner prog! :/

Thank you!
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream>

using namespace 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. ";
		}
		else if (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
	else if (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;
}
Last edited on
closed account (ybf3AqkS)
@SamuelAdams should include the <string> header.
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.

Ref:http://cs.stmarys.ca/~porter/csc/ref/c_cpp_strings.html
Last edited on
else if (income > 15000)

There is no need for this line,

else

alone will do the trick.
Topic archived. No new replies allowed.