Hello Guys, I am currently trying to generate a table output based upon commission rate. With that in mind I am attempting to alter the "rate" variable given a series of "if statements". Here is my code:
public class table_output{ public void sales(double salesAmount) { DecimalFormat formatter = new DecimalFormat("#,###.00"); double Table_cap = salesAmount * 1.5; int fixedsalary = 50000; for(double counter = salesAmount; counter < Table_cap;counter +=5000) { if (counter < 96000) { double rate = 0.00; } else if(counter >= 96000 && counter <= 120000) { double rate = 0.15; } else { double rate = 0.15 * 1.25; } double commissionIncome = counter * rate; //Calculate totalIncome double totalIncome = commissionIncome + fixedsalary; System.out.println(formatter.format(counter))+ " \t " + (formatter.format(totalIncome)); }
However I receive an error to "create local variable 'rate', when trying to formulate double commisionIncome
Please help, and thank you
- Deployment