Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Java 1 I need to come up with a program with the following specs. Prompt the use

ID: 3858394 • Letter: J

Question

Java 1 I need to come up with a program with the following specs.

Prompt the user to input the total sales. That number will be input from the keyboard.

Use if and else statements to determine the appropriate commission rate to be used to calculate the commission on the sales amount entered by the user. Commission is paid at the rate of 2% on any amount of $10,000 or less in sales. Anyone selling over $10,000 is paid at the rate of 5% on the total sales amount.

Declare the necessary variables. Note that in the multiplication of the commission rate the result will potentially have a fractional part. Since the commission rates do not change, initialize them as constants.

Use the if and else statements to determine the appropriate rate for the amount of the total sales, then calculate the commission following the if/else structure.

Output the total sales amount and the commission amount and use appropriate labels for each (see below).

Use text labels on the output which make it clear what information is being displayed. Do not simply use single words like Commission or Total. Single words such as those are not descriptive enough.

Use: good variable names (should be evident what they hold), indentations of four spaces, comments within the body of the program, and label the output appropriately.

Test your program with numbers above and below the commission limits for accuracy in its calculations. Do not submit programs in which the calculations are not done correctly. Try numbers above, below, and at the commission break points.

Format the output using the printf() function. Also use a $ where appropriate.

All methods will be in the same class for this problem. The new methods will be just below the main method.

Place one blank line between each method.

You only need to calculate the commission in one place, rather than having a calculation for each type of commission. Give this aspect of the problem some thought. There are two basic ways you can do this problem as far as the location of the calculation after you have determined the commission rate. Your objective is to do the commission calculation in one place near the end of the program.

Explanation / Answer

CommissionTest.java

import java.util.Scanner;

public class CommissionTest {

public static final int COMMISSION_2 = 2;

public static final int COMMISSION_5 = 5;

public static void main(String[] args) {

Scanner scan = new Scanner(System.in);

System.out.print("Enter the total sales: ");

double totalSales = scan.nextDouble();

double commission = getCommision(totalSales);

double commisionAmount = (totalSales*commission)/100;

printDetails(totalSales, commission, commisionAmount);

}

public static double getCommision(double totalSales) {

if(totalSales < 10000) {

return COMMISSION_2;

} else {

return COMMISSION_5;

}

}

public static void printDetails(double totalSales, double commission, double commisionAmount) {

System.out.println("Total Sales: "+totalSales);

System.out.println("Commision Rate: "+commission);

System.out.println("Commision Amount: "+commisionAmount);

}

}

Output:

Enter the total sales: 15000
Total Sales: 15000.0
Commision Rate: 5.0
Commision Amount: 750.0

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote