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

Create the logic for a program that calls a method that computes the final price

ID: 3778899 • Letter: C

Question

Create the logic for a program that calls a method that computes the final price for a sales transaction. The program contains variables that hold the price of an item, the salesperson's commission expressed as a percentage, and the customer discount expressed as a percentage. Create a calculatePrice() method that determines the final price and returns the value to the calling method. The calculatePrice() method requires three arguments: product price, salesperson commission rate, and customer discount rate. A product's final price is the original price plus the commission amount minus the discount amount. The customer discount is taken as a percentage of the total price after the salesperson commission has been added to the original price. Pseudocode only.

This is a basic computational thinking class. I am not asking for a specific language, rather, a simple code with constants, variables, and the solution.

Explanation / Answer

public class Calculator {

public static void main(String[] args) {

double price = 1299.99;

double commissionRate = 0.2;

double discountRate = 0.25;

double finalPrice;

finalPrice = calculation(price, commissionRate, discountRate);

System.out.println("Final Price: " + finalPrice);

}

private static double calculation(double price, double commissionRate, double discountRate) {

double finalPrice = 0.0;

double priceWCommission = price + (price * commissionRate);

finalPrice = price - (priceWCommission * discountRate);

return finalPrice;

}

}

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