I took out a lot of code, hence all of the variables you can't see, but for some reason, this part is the only one thats screwing up. When you enter zero, its supposed to "cout" a phrase that you don't have money, but when I run it, it tells me when I make 0 dollars a year, I owe 112875 dollars in taxes.

Does anyone see what's wrong with it, or can they run it for me. I have the while file if anyone needs it. But let me know.

Thanks!

-Mike

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

using namespace std;

void main ()
{
	//initialize variables
	int selection = 0;
	double income;
	double taxes = 0;
	int i, c;
	string username;
	string fix;
	string input;




{
	cout << "Please input Head of Household's income here: ";
	cin >> income;
	cout << endl;

	if (income <= 0	)
	{
	cout << "Cannot Compute! You have no money! Why are you doing taxes?" << endl;
	}
		else if (income > 0 && income < 11200)
		{
		        taxes = (income * .1);
		}
		else if (income > 11200 && income <= 42650)
		{
			taxes =	( income - 11200 ) * .15 + 1120;
		}
		else if (income > 42650 && income <= 110100)
		{
			taxes = ( income - 42650 ) *.25 + 5837.5;
		}
		else if (income > 110100 && income <= 178350)
		{
		        taxes = (income - 110100)*(.28) + 22700;
		}
		else if (income > 178350 && income <= 349700)
		{
		       taxes = (income - 178350) *.33 + 41810;
		}
		else if (income > 349700)
		{
		       taxes = ( income - 349700 ) * .35 + 98550.5;
		}

}


//Final output of all tax information
		//Rounded to the nearest dollar value
		cout << "\nYour tax comes out to be: ";
		cout << setiosflags(ios::fixed) << setprecision(0) << taxes;
		cout << " Dollars.\n\n" << endl;

}

I'm using the same program.

Yours ran a cout when you entered zero? Well, then it's wrong somewhere else. I have four steps of this. Single, Married, Married and Separate and Head of Household. The first two run well and the second 2 fail with the zero test. Hmmmm...

-mike

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