# need help creating a Commission Calculator

• March 19th, 2014, 10:14 PM
Rhiannon1488
need help creating a Commission Calculator
I need to create a simple Java program for a commission calculator with the following requirements:
I need to ask the user to enter their total sales (as a double) in at the keyboard and I need to use "if" statements to tell them
their commission (sales * commission rate) using the following criteria:
o < \$8000 in sales – Commission rate = 10%
o \$8000 to \$12000 in sales – Commission rate = 12%
o \$12000.01 to \$18000 in sales – Commission rate = 15%
o \$18000.01 to \$20000 in sales – Commission rate = 18%
o > \$20000 in sales – Commission rate = 20%
Then for the output the user’s Commission in a well formatted way (use the DecimalFormat class)
In comment blocks have a description of what the program does. thank you! I think I did something wrong here is mine
Code Java:

```import java.util.Scanner;   public class CommissionCalculator //This program calculates the commission of sales { public static void main(Strings[] args) { // create a scanner Scanner input = new Scanner(System.in); //define variable double sales; //inputted sales amount double commission = 0; //commission pay amount     System.out.print("Please enter sales amount:");   double sales = input.nextDouble();   if (sales > 20000.01 )   commission = sales * .20;   else if (sales > 18000.01 && sales <= 20000)   commission = sales * .18;   else if (sales > 12000.01 && sales <= 18000)   commission = sales * .15;   else if (sales > 8000.01 && sales <= 12000)   commission = sales * .12;   else (sales <= 8000)   commission = sales * .10;   { System.out.println("Your Commission + sales total is :\$" + mask.format((sales));} }   }```
• March 19th, 2014, 10:31 PM
dicdic
Re: need help creating a Commission Calculator
Hi, Welcome to the forum! Please read Announcements - What's Wrong With My Code? for guidlines on how to code
Quote:

I think I did something wrong here is mine
so what is wrong?

• March 20th, 2014, 08:11 PM
dicdic
Re: need help creating a Commission Calculator
Quote:

public static void main(Strings[] args)
the argument should be String[] args not Strings[]

Quote:

else (sales <= 8000)
you don't have to put condition in else keyword.
the program will read the statements in else when the if and else if condition falls to false.

Quote:

if (sales > 20000.01 )

commission = sales * .20;

else if (sales > 18000.01 && sales <= 20000)

commission = sales * .18;

else if (sales > 12000.01 && sales <= 18000)

commission = sales * .15;

else if (sales > 8000.01 && sales <= 12000)

commission = sales * .12;

else (sales <= 8000)

commission = sales * .10;
please don't put carriage return every after conditional statement since you are not using braces,
and please, use braces every conditional statement.

Quote:

{