Hi I need help with some C++ code. It's pretty basic, but my teacher will not help me. He keeps saying "Just one second, I'm helping someone else." And then forgets about me. It just gets frusturating. The code is very undeveloped though, I'm just trying to get all the basic bugs out. It's supposed to calculate tax based on income and marriage status. Here it is:

#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>

using namespace std;

int marriage();

int marincome();

int sincome();

int main()
{
	system("cls");
	
	marriage();


	return 0;
}

int marriage()
{	
	string status = " ";

	cout << "Are you married?" << endl;
	cin >> status;
	
	if status = "Yes";
	{
		marincome();
	}
	else if status = "No";	
	{
		sincome();
	
	}
	else
	{
		goto 

	return 1;
}

int marincome()
{
	int remainder = 0;
	remainder = dividend % divisor;
	return 0;
}

Here are my errors:

(31) : error C2061: syntax error : identifier 'status'
(35) : error C2181: illegal else without matching if
(35) : error C2061: syntax error : identifier 'status'
(40) : error C2181: illegal else without matching if
(44) : error C2059: syntax error : 'return'
(48) : error C2601: 'marincome' : local function definitions are illegal
(25): this line contains a '{' which has not yet been matched
(53) : fatal error C1075: end of file found before the left brace '{'

What's really bothering me is all the illegal elses. Also many of these errors I think I can fix myself, but I just didn't have the time if I wanted to get any help. Thanks in advance.

Hi I need help with some C++ code. It's pretty basic, but my teacher will not help me. He keeps saying "Just one second, I'm helping someone else." And then forgets about me. It just gets frusturating. The code is very undeveloped though, I'm just trying to get all the basic bugs out. It's supposed to calculate tax based on income and marriage status. Here it is:

#include <iostream>
#include <iomanip>
#include <cmath>
#include <string>

using namespace std;

int marriage();

int marincome();

int sincome();

int main()
{
	system("cls");
	
	marriage();


	return 0;
}

int marriage()
{	
	string status = " ";

	cout << "Are you married?" << endl;
	cin >> status;
	
	if status = "Yes";
	{
		marincome();
	}
	else if status = "No";	
	{
		sincome();
	
	}
	else
	{
		goto 

	return 1;
}

int marincome()
{
	int remainder = 0;
	remainder = dividend % divisor;
	return 0;
}

Here are my errors:

(31) : error C2061: syntax error : identifier 'status'
(35) : error C2181: illegal else without matching if
(35) : error C2061: syntax error : identifier 'status'
(40) : error C2181: illegal else without matching if
(44) : error C2059: syntax error : 'return'
(48) : error C2601: 'marincome' : local function definitions are illegal
(25): this line contains a '{' which has not yet been matched
(53) : fatal error C1075: end of file found before the left brace '{'

What's really bothering me is all the illegal elses. Also many of these errors I think I can fix myself, but I just didn't have the time if I wanted to get any help. Thanks in advance.

Tips, don't use gotos, check how to write if statements.

Check how to compare strings ( double equal sign == )

If you write a function make sure it is done correctly. Make sure the function definition exists!

The condition for an if statement needs to be enclosed in parenthesis and shouldn't have a semicolon at the end, e.g.

if (condition)
{
    statement;
}

Also, "=" is the assignment operator, what you want to use in the if statements is "==" the equal-to comparison operator. You are also missing a closing brace by your last else clause.
I think there are a few other problems, but this will hopefully get you started.

Edited 6 Years Ago by DarkSentinel: n/a

> if status = "Yes";
Read your text book again, the outermost ( ) are ESSENTIAL, that is part of the language, and not a wrapper around an expression (one of their other uses).

This article has been dead for over six months. Start a new discussion instead.