'Expression must have bool type' error?

I was prompted to make 'state' a string variable but I can't work out this problem on my own.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

	char homeownerStatus;
	char y, Y;
	string state;
	double income;
	string MO, mo, Mo, KS, ks, Ks;
	double creditAmount;

	cout << endl;
	cout << "Are you a homeowner [Y/N]?";
	cin >> homeownerStatus;

	if (homeownerStatus == Y || y)
	{
		cout << "Resident state [MO or KS]: ";
		cin >> state;

		if (state == MO,mo,Mo)                     
		{


at if (state == MO,mo,Mo)
it says state must be boolean but I don't know where to go from here.
(homeownerStatus == Y || y)
This is wrong. You almost certainly meant:
(homeownerStatus == 'Y' || homeownerStatus == 'y' )

if (state == MO,mo,Mo)
This is very wrong. Where did you get this?
I expect you meant:
if (state == "MO" || state == "mo" || state == "Mo")
Last edited on
It's an old assignment and I had cobbled my code together from the resources I could find online. I have trouble paying attention in class and my notes are scattered all over. With your help I was able to have it run perfectly. Thank you!
Topic archived. No new replies allowed.