Help with this code | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Help with this code

was wondering if someone could help with this code?? when you type in a value that exceeds the 2nd limitation, the result is generated from the 2nd tier. thank you in advance!!! #include <iostream> using namespace std; int main() { int x; float a, b, c, d, e, f, y1, y2, y3, y4, y5, y6; a = 1.03; b = 1.05; c = 1.07; d = 1.09; e = 1.15; f = 1.25; cout << "Please enter your income: " ".\n"; cin >> x; if (x <= 7500){ y1 = x * a; cout<<"Your taxed value is 1: " << y1 << endl; } else if (7501 >= x <= 15000){ y2 = x * b; cout<<"Your taxed value is 2: " << y2 << endl; } else if (15001 >= x <= 25000){ y3 = x * c; cout<<"Your taxed value is 3: " << y3 << endl; } else if (25001 >= x <= 50000){ y4 = x * d; cout<<"Your taxed value is 4: " << y4 << endl; } else if (50001 >= x <= 100000){ y5 = x * e; cout<<"Your taxed value is 5: " << y5 << endl; } else if (x >= 100001){ y6 = x * f; cout<<"Your taxed value is 6: " << y6 <<endl; } return 0; }

16th Sep 2019, 2:07 PM
AJ Makries
AJ Makries - avatar
1 Answer
+ 3
if(constantValue/expression >= x && x <= constantValue/expression) So it should be like this if(7501 >= x && x <= 15000) And similarly in all other cases.
16th Sep 2019, 3:18 PM
blACk sh4d0w
blACk sh4d0w - avatar