Results 1 to 2 of 2
  1. #1
    462345 is offline Member
    Join Date
    Mar 2013
    Posts
    1
    Rep Power
    0

    Default Another Loop Question

    fixed earn 30000:::target sales 120000:::%5 commission:::1.25 accelerator

    Java 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?
    Last edited by JosAH; 03-28-2013 at 09:25 PM.

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,770
    Blog Entries
    7
    Rep Power
    21

    Default Re: Another Loop Question

    Don't hijack someone else's thread; I moved your post to its own thread (and added code tags, but it didn't help much).

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Question about while loop
    By sleshas in forum New To Java
    Replies: 3
    Last Post: 03-20-2012, 07:22 PM
  2. Do....while Loop question
    By Roter in forum New To Java
    Replies: 10
    Last Post: 01-25-2012, 05:49 AM
  3. Loop question
    By rich123 in forum New To Java
    Replies: 6
    Last Post: 02-08-2011, 03:26 AM
  4. for Loop with Yes/No Question! help..please!
    By mastercrimson in forum New To Java
    Replies: 8
    Last Post: 06-02-2010, 06:08 PM
  5. Question about for loop..
    By sivakumar_sakam in forum New To Java
    Replies: 4
    Last Post: 05-16-2009, 12:23 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •