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

Write a C++ program that calls a method (function ) that computes the final pric

ID: 3569734 • Letter: W

Question

Write a C++ program that calls a method (function ) that computes the final price of a sales transaction . the program contains variables that holds the price of an item , the salespersons commission expressed as percentage , and the customer discount expressed as a percentage . program should call a function calculateprice () that determines the final price and returns the value to the calling function.

The calculateprice() requires three argument: product price, salesman's commission reat, and customer discount rate. The 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.

Explanation / Answer

#include<iostream>

using namespace std;

//function to calculate final price

double calculateprice (double price,double commission,double discount)

{

       return ((price*(1+commission/100.0))*(1-discount/100.0));

}

//driver function main

int main()

{

    double price,commission,discount;

   

    cout<<"Enter price of an item: ";

    cin>>price;

    cout<<" Enter salespersons commission: ";

    cin>>commission;

    cout<<" Enter customer discount: ";

    cin>>discount;

   

    double final_price = calculateprice (price,commission,discount);

   

    cout<<" Final price of the product: "<<final_price;

    return 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