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

Exercise 4:Design and implement a Java program for programming exercise 6.11, pa

ID: 3725646 • Letter: E

Question

Exercise 4:Design and implement a Java program for programming exercise 6.11, page 236 (name it ComputeCommiasiona), to print out a table of sales amounts and commissions as shown in the textbook Follow the instructions in the problem statement (the program takes no input from the user and all output is generated by the main method). Document your code and follow the output model shown in the textbook (Financial application: compute commissions) Write a method that computes commission, using the scheme in Programming Exercise 5.39. The header of the method is as follows: the 6.11 public static double computeCommission (double salesAmount) Write a test program that displays the following table: Sales Amount 10000 15000 Commission 900.0 1500.0 95000 100000 11100.0 11700.0 Please write this Java program as simple as possible and with comments throughout to explain what is happening. Thank you!

Explanation / Answer

ComputeCommissions.java

public class ComputeCommissions {

public static void main(String[] args) {

System.out.println("Sales Amount Commision");

for(int sales=10000;sales<=100000;sales+=5000) {

System.out.println(sales+" "+computeCommission(sales));

}

}

public static double computeCommission(double salesAmount) {

double balance, // Holds the balance

commission;

balance = commission = 0.0; // Initialize balance and commission to 0

// If sales amount is $10.000.01 and above commission rate is 12%

if (salesAmount >= 10000.01)

commission += (balance = salesAmount - 10000) * 0.12;

// If sales amount is $5,000.01 to $10,000 commissin rate is 10%

if (salesAmount >= 5000.01)

commission += (balance -= balance - 5000) * 0.10;

// If sales amount is $0.01 to $5,000.01 commissin rate is 8%

if (salesAmount >= 0.01)

commission += balance * 0.08;

return commission;

}

}

Output:

Sales Amount Commision

10000 900.0

15000 1500.0

20000 2100.0

25000 2700.0

30000 3300.0

35000 3900.0

40000 4500.0

45000 5100.0

50000 5700.0

55000 6300.0

60000 6900.0

65000 7500.0

70000 8100.0

75000 8700.0

80000 9300.0

85000 9900.0

90000 10500.0

95000 11100.0

100000 11700.0