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

For this problem, follow the instructions for Program #5 in Chapter 3 Exercises

ID: 3530886 • Letter: F

Question

For this problem, follow the instructions for Program #5 in Chapter 3 Exercises of your textbook. Remember the following points: Create an application that contains a method that computes the final price for a sales transaction and returns that value to a calling method. The 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. Write a main() method that prompts the user for the price of an item, the salesperson's commission expressed as a percentage, and the customer discount expressed as a percentage, and that then passes the values to the method. Save the application as Calculator.java

Explanation / Answer

//Calculator.java

import java.util.Scanner;


public class Calculator {


public static double getFinalPrice( double product_price, double commission_rate,double customer_dct_rate){

double commission =commission_rate*product_price/100.0;

return (product_price+ commission)*(1-(customer_dct_rate/100.0));

}

public static void main(String[] args) {

Scanner input=new Scanner(System.in);

double price, cRate, dRate;

System.out.print("Enter product price: ");

price=input.nextDouble();

System.out.print("Enter salesperson commission rate (in percent form): ");

cRate=input.nextDouble();

System.out.print("Enter customer discount rate (in percent form): ");

dRate=input.nextDouble();

System.out.printf("The final price is $%.2f",getFinalPrice(price,cRate,dRate));

input.close();

}


}

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