java program

I have to write a java program that calculates sales commission. the sales people receive  $200 per week plus 9% of their gross sales.  We were supplied item 1 239.99, item 2 129.75, item 3 99.95, item 4 350.89.

The java program has to calculate and display earnings of one sales person. there is no limit to the number of items sold
I have been able to successfully increment the counter but I cannot get total earnings to display. Here is my code.

import java.util.Scanner; //program uses class Scanner

public class SalesCommission
      //main method begins execution of Java application
      public static void main(String[] args)
            double pay = 0.0;
            double earnings;
            int ItemCounter = 0; // initialize # of items to be entered next
            int AmountSold;
            // create a Scanner to obtain input from the command window
                        Scanner input = new Scanner(;
            while (ItemCounter < 4) // loop 4 times
                  ItemCounter ++; // increment counter by 1
                  System.out.print(" Enter amount sold of item  #" + ItemCounter + ":");
                  AmountSold = input.nextInt(); // input next amount sold
            if ( ItemCounter == 1 )
                  pay += AmountSold * 239.99;
            else if ( ItemCounter == 2 )
                  pay += AmountSold * 129.75;
            else if ( ItemCounter == 3 )
                  pay += AmountSold * 99.95;
            else if ( ItemCounter == 4 )
                  pay += AmountSold * 350.89;
            } // end while
            earnings = 0.09 * pay + 200;
            System.out.printf("%nAmount of salesperson pay for the week %d ", (earnings) );

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Change the line

 System.out.printf("%nAmount of salesperson pay for the week %d ", (earnings) );


 System.out.printf("%nAmount of salesperson pay for the week %f ", (earnings) );

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Rhiaanon44Author Commented:
Great it worked perfectly.
Consider using double[] for your multiplier
Also, variable names in Java begin lower case and are in camel case
Rhiaanon44Author Commented:
Thank you CEHJ!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.