I'm trying to calculate the income tax one would recieve in 1913, following these rules: The original U.S. income tax of 1913 was
• 1 percent on the first $50,000.
• 2 percent on the amount over $50,000 up to $75,000.
• 3 percent on the amount over $75,000 up to $100,000.
• 4 percent on the amount over $100,000 up to $250,000.
• 5 percent on the amount over $250,000 up to $500,000.
• 6 percent on the amount over $500,000.
I've written this so far (don't know if I've formatted it correctly, sorry in advance)
include <iostream>
include <iomanip>
using namespace std;
int main() { double salary = 0.0;
cout << "How much money did you make this year?";
cin >> salary;
double incomeTax1913;
if (0 < salary <= 50000)
{
incomeTax1913 = salary*.01;
}
else
{
if (50000 < salary < 75000)
{
incomeTax1913 = (salary-50000)*.02 + 500;
}
else
{
if (75000 < salary < 100000)
{
incomeTax1913 = (salary-75000)*.03 + (salary-50000)*.02 + 500;
}
else
{
if (100000 < salary < 250000)
{
incomeTax1913 = (salary-100000)*.04 + (salary-75000)*.03 + (salary-50000)*.02 + 500;
}
else
{
if (250000 < salary < 500000)
{
incomeTax1913 = (salary-250000)*.05 + (salary-100000)*.04 + (salary-75000)*.03 + (salary-50000)*.02 + 500;
}
else
{
if (salary > 500000)
{
incomeTax1913 = (salary-500000)*.06 + (salary-250000)*.05 + (salary-100000)*.04 + (salary-75000)*.03 + (salary-50000)*.02 + 500;
} // no else needed
}
}
}
}
}
cout << "Your income tax in 1913 would be $";
cout << fixed << setprecision(2);
cout << incomeTax1913;
return 0;
}
When I input a salary value (123456.78) I get 12345.67 as the income tax amount. This is obviously incorrect, as my own calculations confirm.
Where did I go wrong?
>>55197357
by posting this thread and not killing yourself
>>55197357
1. Use sqt for this kind of stuff, read the sticky
2. [.code] [./code] for code tags
3. Didn't bother readying the whole thing, but
>if (0 < salary <= 50000)
Does C++ support this?
I would assume that 0 < salary would evaluate to true (nonzero value) then it would be, if for example that nonzero value was -1,
if (-1 <= 50000)
{
// stuff
}
What if you did0 < salary && salary <= 50000
>>55197503
[.code]testing[./code]
>>55197549
[.code] testing [./code]
I'd ask >>>/biz/
>>55197549
>>55197563
Are you legitimately retarded?