Could someone please check my answer forthe question below and tell me if it is correct.
Implement a method showTaxAmount to show the tax paid for payment amount from 1000 to 55000 with incremental of 100.
public void showTaxAmount(int payment)
if (payment >= 1000 && payment <= 55000 && (payment%100 == 0) )
System.out.println("Tax paid for " + payment + " is "+ payment*TAX_RATE);
System.out.println("Payment should be from 1000 to 55000 with incremental of 100");
But a forummer suggested that I need a loop for this question because it states "increments of 100".
I can understand that - it isn't clear in the question what 'incremental of 100' means - I guessed it from the code you wrote...
However, in programming, regular increments usually mean iteration with addition, so the question could be interpreted as asking for code that displays the tax paid for all the values from 1000 to 55000 in increments of 100, in which case you would have to wrap the current method code in a loop. It is a poorly worded and ambiguous question.
Good teaching is more a giving of the right questions than a giving of the right answers...
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.