131k views
1 vote
The dealer’s cost of a car is 85% of the listed price. The dealer would accept any offer that is at least $500 over the dealer’s cost. Design an algorithm that prompts the user to input the list price of the car and print the least amount that the dealer would accept for the car. C++

1 Answer

0 votes

Here is an algorithm in C++ that prompts the user to input the list price of the car and prints the least amount that the dealer would accept for the car:

#include <iostream>

using namespace std;

int main() {

double list_price, dealer_cost, min_accepted_price;

const double DEALER_COST_PERCENTAGE = 0.85;

const double MIN_ACCEPTED_PRICE_OVER_COST = 500;

cout << "Enter the list price of the car: ";

cin >> list_price;

dealer_cost = list_price * DEALER_COST_PERCENTAGE;

min_accepted_price = dealer_cost + MIN_ACCEPTED_PRICE_OVER_COST;

cout << "The least amount the dealer would accept for the car is: $" << min_accepted_price << endl;

return 0;

}

The algorithm starts by including the library iostream and declaring the namespaces. Then it declares the variables that will be used in the program (list_price, dealer_cost, min_accepted_price) and the constants that will be used (DEALER_COST_PERCENTAGE and MIN_ACCEPTED_PRICE_OVER_COST). Then it prompts the user to enter the list price of the car. Next, it calculates the dealer's cost by multiplying the list price by the dealer cost percentage and the minimum amount the dealer would accept by adding the dealer's cost to the minimum accepted price over cost. Finally, it prints the least amount the dealer would accept for the car.

User JonCole
by
7.8k points