Charles Angemeyer wrote:I have to get the user to input their taxable income and filing status (0 to 3). No problem there.
Then depending on these two things apply the correct equation to determine their taxable income.
I originally thought 'switch' but can switch handle two variables? Therefore I turned my thoughts to if-then...
Whoa hoss, you're overthinking this.
You're also trying to work out
how you're going to do this in Java rather than analysing
what needs to be done.
My advice (and it's always the same in cases like this):
StopCoding (←click).
Ask yourself a few questions:
1. What are these equations?
2. How are they affected by your two parameters (filing status and income bracket)? Is there, for example, any formula that can be applied to the two together?
The answers may give you a good idea of how to set up your program, but
do your thinking on paper; and
don't write a line of Java code until you can describe your solution completely in English (or your native language).
Personally, I'd consider creating enums for
both your parameters, for example:
which provides you with a foundation for adding any calculation based on income bracket.
Note that the above is just an example; there are
many other ways of doing this.
It's also worth noting that you
can use enums in
switch statements; but if you design your program properly, you shouldn't have to.
HIH
Winston