I'm struggling to get the incentive part correct. And I have no idea where to start to display the table. Here are the instructions and the code below.
· A salesperson will continue to earn a fixed salary of $50,000.00 per year. The current sales target for every salesperson is $120,000.00 per year.
· The sales incentive will only start when 80% of the sales target is met. The current commission is 7.5% of total sales.
· If a salesperson exceeds the sales target, the commission will increase based on an acceleration factor. The acceleration factor is 1.25.
· The application should ask the user to enter annual sales, and it should display the total annual compensation.
· The application should also display a table of potential total annual compensation that the salesperson could have earned, in $5000 increments above the salesperson’s annual sales, until it reaches 50% above the salesperson’s annual sales.
Sample Table: Assuming a total annual sales of $100,000, the table would look like this:
Total Sales Total Compensation
100,000 <Program Calculated Value>
105,000 <Program Calculated Value>
<etc>
Here's what I have so far.
package commissioncalculator; import java.text.DecimalFormat; import javax.swing.JOptionPane; /** * @author Marci */ public class CommissionCalculator { /** * @param args the command line arguments */ public static void main(String[] args) { String input; //Input of user double salary; //This is the annual sales value double rate; //This is the commission rate double commission; //This is the amount of commision made double pay; //Salesperson's pay double sales; //annual sales double incentive; //sales incentive DecimalFormat dollar = new DecimalFormat("#,##0.00"); DecimalFormat percent = new DecimalFormat("##0.0%"); input = JOptionPane.showInputDialog("Enter the annual salary."); salary = Double.parseDouble(input); input = JOptionPane.showInputDialog("Enter current commission rate."); rate = Double.parseDouble (input); input = JOptionPane.showInputDialog("Enter the current sales target."); sales = Double.parseDouble (input); commission = rate * salary; pay = commission + salary; JOptionPane.showMessageDialog(null, "Commission rate is " + percent.format(rate) + ". The amount of pay is $" + dollar.format(pay)); public incentive() { if (sales>=(.80 * sales) && sales<=120,000) incentive = (.75 * sales); else if (sales>120,000) incentive = (1.25 * .75 * sales); } } System.exit(0); }