I have been working on this program to calculate a sales commission and failing miserably. I need to get this program working so I can then modify it to add an array to calculate and compare the sales info for 2 sales people. And it's all due Monday!!
Someone PLEASE take a look at this code and tell me how to fix it. I am at my wits end here.
Thanks in advance for your help!!
package compensation; import java.text.DecimalFormat; import java.util.Scanner; /** * @author Rick Sebastian */ public class Compensation { public static double main(String[] args) { int salary = 60000; //Defines base salary of $60K double targetSales = 120000; //Defines the target sales object to determine commission double sales; //Defines sales amount double commission = 0.025; double accelerator = 0.0125; double minSalesamt = 960000; double compensation; //Defines compensation object that combines salary + commission double overSales; double regCommission; double aclCommission; final int INCREMENT = 5000; //Defines sales increment to calculate potential compensation int total; // To hold the total sales in total DecimalFormat formatter = new DecimalFormat("#0.00"); Scanner keyboard = new Scanner(System.in); //Code needed to prompt user to enter info on keyboard System.out.print("Enter total annual sales figure: $ "); //Prompts user to enter sales figure sales = keyboard.nextDouble(); { if (sales < minSalesamt) { compensation = salary; return compensation; //This represents everything less than the 80% of the $1.2M sales goal where no commission is paid } if (sales > targetSales) { overSales = (sales - targetSales); aclCommission = (overSales * (commission + accelerator)); sales = targetSales; } else { aclCommission = 0; } regCommission = (sales * commission); compensation = (salary + regCommission + aclCommission); System.out.println("Your total annual compensation is $" + compensation); //This code displays the total compensation including salary + commission System.out.println("Potential Total Sales\tMax Potential Salary Total"); // Display the table headings. System.out.println("------------------------------------------"); for (total = (int) sales; total <= sales * 1.5; total += INCREMENT) // Loop to calculate the Total Potential Sales and Total Potential Compensation { System.out.printf("%20d\t\t%,.2f\n", total, compensation); // Display the Potential Total Sales and Total Potential Annual Compensation } } return 0; } }