In: Computer Science
PLEASE TYPE OUT IN TEXT (please no pdf or writing)
C++ PLEASE
Summary
For each used car a salesperson sells, the commission is paid as follows: $20 plus 30% of the selling price in excess of the cost of the car.
Typically, the minimum selling price of the car is the cost of the car plus $200 and the maximum selling price is the cost of the car and $2,000.
Instructions
Write a program that prompts the user to enter:
The program should output:
Since your program handles currency, make sure to use a data type that can store decimals.
C++ Program:
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
double purCost, minAdd, maxAdd, fixedComm, commPercentage, minSP, maxSP, commLow, commHigh;
cout << fixed << setprecision(2);
//Reading input from user
cout << "Enter Purchasing cost of the car: $";
cin >> purCost;
cout << "Enter minimum to be added to the purchasing cost: $";
cin >> minAdd;
cout << "Enter maximum to be added to the purchasing cost: $";
cin >> maxAdd;
cout << "Enter salesperson fixed commission: $";
cin >> fixedComm;
cout << "Enter salesperson Percentage of commission: ";
cin >> commPercentage;
// Calculatin minimum and maximum selling price of the car
minSP = minAdd + purCost;
maxSP = maxAdd + purCost;
//Calculating salesperson commission range
commLow = fixedComm + ( (commPercentage/100.0) * minAdd );
commHigh = fixedComm + ( (commPercentage/100.0) * maxAdd );
//Printing results
cout << "\n\n Minimum Selling Price of the Car: $" << minSP;
cout << "\n Maximum Selling Price of the Car: $" << maxSP;
cout << "\n Salesperson Commission Range: $" << commLow << " to $" << commHigh << "\n\n";
return 0;
}
Sample Run: