[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y ] [Home]
4chanarchives logo
I'm trying to calculate the income tax one would recieve

You are currently reading a thread in /g/ - Technology

Thread replies: 7
Thread images: 1
File: SHPAYCE.jpg (3 MB, 3840x2160) Image search: [Google]
SHPAYCE.jpg
3 MB, 3840x2160
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 did
0 < salary && salary <= 50000
>>
>>55197503
[.code]testing[./code]
>>
>>55197549
[.code] testing [./code]
>>
I'd ask >>>/biz/
>>
>>55197549
>>55197563
Are you legitimately retarded?
Thread replies: 7
Thread images: 1

[Boards: 3 / a / aco / adv / an / asp / b / biz / c / cgl / ck / cm / co / d / diy / e / fa / fit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mu / n / news / o / out / p / po / pol / qa / r / r9k / s / s4s / sci / soc / sp / t / tg / toy / trash / trv / tv / u / v / vg / vp / vr / w / wg / wsg / wsr / x / y] [Home]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
If a post contains personal/copyrighted/illegal content you can contact me at [email protected] with that post and thread number and it will be removed as soon as possible.
If a post contains illegal content, please click on its [Report] button and follow the instructions.
This is a 4chan archive - all of the content originated from them. If you need information for a Poster - you need to contact them.
This website shows only archived content and is not affiliated with 4chan in any way.
If you like this website please support us by donating with Bitcoin at 1XVgDnu36zCj97gLdeSwHMdiJaBkqhtMK