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.javaExplanation / 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();
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.