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 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;

}``````

worked for me using VC++ 2008 Express. What compiler and os did you use?

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

Worked for me too. For the heck of it, maybe change:

``double taxes = 0;``

to

``double taxes = 0.0;``

Worked fine for me with the former, but the latter is probably better. Also see this for "void main ()".

Alright! Thanks, I got it to run. Thanks for the help!

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.