# Another Loop Question

• 03-28-2013, 07:05 PM
462345
Another Loop Question
fixed earn 30000:::target sales 120000:::%5 commission:::1.25 accelerator

Code:

```/*This program will ask the user to enter annual sales, * and it should display the total annual compensation. * This program will also display a table of potential * total annual compensation that the salesperson's * annual sales, until it reaches 50% above the * salesperson's annual sales. */ import java.text.NumberFormat; import java.util.Locale; import java.util.Scanner; /** * */                   { /** * @param args the command line arguments */ public static void main(String[] args) { // Command to format currency NumberFormat numberFormat = NumberFormat.getCurrencyInstance(Locale.US); // Command for accepting input Scanner input = new Scanner(System.in); // Command to prompt the user and accept sales amount System.out.print("Enter sales: "); double sales = input.nextDouble(); // Assume base salary of 30000 and commission rate of 5% double fixedSalary = 30000; double commissionRate = 0.05; // Command to initialize sales person object with default values SalesPerson salesPerson = new SalesPerson(fixedSalary, commissionRate); // Command to calculate the total compensation and display it in // currency format System.out.println("Total compensation: " + numberFormat.format(salesPerson.calculateTotalComp ensation(sales))); // Create table for possible total compensation double maxSales = 1.25 * sales; double salesAmount = sales; System.out.println("Total Sales\t\tTotal compensation"); while (salesAmount <= maxSales) { System.out.println(numberFormat.format(salesAmount ) + "\t\t" + numberFormat.format(salesPerson.calculateTotalComp ensation(salesAmount))); salesAmount = salesAmount + 5000; OUTPUTS:::: Enter annual sales for the salesperson: 100000 Total annual compensation = \$35,000.00 Annual Sales                Total annual compensation \$100,000.00                \$35,000.00 \$105,000.00                \$35,250.00 \$110,000.00                \$35,500.00 \$115,000.00                \$35,750.00 \$120,000.00                \$36,000.00 \$125,000.00                \$186,250.00```
BUILD SUCCESSFUL (total time: 6 seconds)
I DID SOMETHING WRONG SOMEWHERE ANY HELP?
• 03-28-2013, 09:27 PM
JosAH
Re: Another Loop Question