Hi I'm a complete noob to programming but am trying to learn c++. Im having trouble with a small project that I was given and was wondering if anyone could help me out.
Here is the sample project that I was given:

A certain country charges its citizens an annual income tax. The first $5000 of income is tax-free; the next $10,000 is taxed at 12%; any amount after that is taxed at 23%.

An employee of the taxation department of the government wants a procedure that will calculate a citizen’s income tax amount owed. Given the gross annual pay amount, he wants to know the amount of tax owed and how much money the citizen has ‘left over’ after tax.


Heres my rough draft:

#include "stdafx.h"
#include <iostream>
using namespace std;

int grossIncome;
int taxRate;
int taxesPayed;
int netIncome;


int _tmain(int argc, _TCHAR* argv[])
{

	cout << "This program will calculate how much taxes will be deducted " <<endl;
	cout << "from your gross income. " << endl;
	cout << "It will then display how much taxes you are paying," << endl;
	cout << "as well as how much your income will be after tax deductions" << endl << endl;
	cout << "Enter your Gross Income " << endl <<endl;
	
	cin >> grossIncome;

	if ( grossIncome < 5000 )

	{
		
		taxRate = 0;
	}


	else

		if ( grossIncome < 10000 )

		{
			  taxRate = 12;

		}
		
		else 

			if ( grossIncome > 10000)

			{
				taxRate = 23;
			}	
	
			
	if ( taxRate = 0 )

	{
		taxesPayed = 0;
	}
	
	else 

		if ( taxRate = 12 )
		
		{
			taxesPayed = grossIncome * .12;
		}
		
		else 
			
			if ( taxRate = 23 )
			
			{
				taxesPayed = grossIncome * .23;
			}
	
	cout << endl << taxesPayed <<endl;

	netIncome = grossIncome - taxesPayed;

			cout << netIncome;

	return 0;
}

The problem I'm having is that it always calculates the tax rate at 12% no matter what value I input. This is driving me nuts can anyone plz help??
thx in advance.

Recommended Answers

All 2 Replies

Use == for comparison, = is for assignment.

Wow ... that was simple. Thx A lot Narue - works fine now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.