#include <iostream>
usingnamespace std;
int main ()
{
float a, b, c, d, e, f, g (0);
while (a > 0){
cout << "How much is your yearly taxable income? ";
cin >> a;
if (a > 349700){
a = a - 349700;
b = a * .35;
a = 349700;
}
if (a > 160850){
a = a - 160850;
c = a * .33;
a = 160850;
}
if (a > 77100){
a = a - 77100;
d = a * .28;
a = 77100;
}
if (a > 31850){
a = a - 31850;
e = a * .25;
a = 31850;
}
if (a > 7825){
a = a - 7825;
f = a * .15;
a = 7825;
}
if (a > 0){
g = a * .10;
}
cout << b+c+d+e+f+g << endl;
}
system("pause");
return 0;
}
I know my coding probably looks like crud but anyways my problems are:
1.)Lets say that the first value I input is 350,000. So it runs the first if statement and all the rest that follow. But then lets say I enter 200,000 next. It saves the value of b and adds it to the true value for 200,000. Is there a way I can 'clear' the variables back to 0 at the end of the loop maybe?
2.) It prints the correct values for any number I enter over 77,100 but gives me 5.34649e+036 for any value under that. Any help would be greatly appreciated.