Hey, I'm having trouble using a loop statement in a multiway if else statement. Is there anyway i can run my code using a loop statement to give the user the amount in tax and keep asking them until they enter a 0 or 0.0
Okay, so first of all, you might want to change int incomeYearly to double incomeYearly. Technically, you don't need to, but whenevery I'm working with decimals, I try not to use int because it chops off the decimals.
I noticed you put a returntrue; in every if-statement. That tells the program to end the function right there. Literally. It "returns". So you don't want return statements in there.
There are many ways to do what you want, but one way I can think of right now is to create a variable that equals 1 or zero. So instead of putting the returnfalse; statements, you write counter = 1; //assuming you created a variable named counter..and dont include this comment, lol .
And then at the bottom, you can put the cout statement inside an if-statement.
1 2 3 4 5 6 7 8 9
if (counter == 1){
//cout statement here.
returntrue; //Here is where you return. The function is done.
}
else{//none of the if-statements were executed, meaning the user must have entered in zero, so counter stayed at 0.
returnfalse;
}