STRICTLY USE TEMPLATE PROVIDED AT END OF QUESTION. ---------------------------------- On account of Diwali, a pre-owned Car Dealer “Silicon Motors”, has announced attractive discount sales. The Outlet Head has fixed the discount rates of the Cars based on the years of usage and condition of a car. Akash, a teenager wished to buy an economical pre-owned Car of any famous brand but that was in pretty good condition. Having known about the discount offers at “Silicon Motors”, he visited the showroom to see if he could get convincing Models. After glimpsing through the Cars in the display, Akash wanted to calculate the discount price for those Cars that he was interested in so that he could conclude his selection. Write a C++ program to calculate the discount price of the Cars of his choice. Strictly adhere to the Object-Oriented specifications given in the problem statement. All class names, member variable names, and function names should be the same as specified in the problem statement. Consider a class called Car which has the following private variables. Datatype Variable string model double price string condition int year Include the following overloading function in the class Car. Function Name Description void price(string model, double price) This function displays the model and actual price of the car. void price(string model, double price, string condition, int year) This function is used to calculate the price after the discount of the car based on the years of usage and condition of the car. If the years of usage is less than 3 years and the car condition is good the discount will be 20%. If the years of usage is greater than 5 years and the car condition is good, then the discount will be 40%. If the years of usage is greater than 5 years and the car condition is moderate, then the discount will be 50%. If the years of usage is greater than 5 years and the car condition is poor, then the discount will be 60%. Input and Output Format: All double values should be displayed with two decimal places. Refer sample input and output for formatting specifications. [All text in bold corresponds to input and the rest corresponds to the output] Sample Input and Output 1: Enter the model of the car verna Enter the actual price of the car 150000 Enter the years of usage of the car 2 Enter the condition of the car good Car Details Model : Verna Actual Price : 150000 Price after discount : 120000 -----------End Of Question----------- TEMPLATE BELOW car.cpp using namespace std; class Car { private: string model; double price; string condition; int year; public: void price(string model,double price){ //Fill your code here } void price(string model,double price,string condition,int year){ //Fill your code here } };
STRICTLY USE TEMPLATE PROVIDED AT END OF QUESTION.
----------------------------------
On account of Diwali, a pre-owned Car Dealer “Silicon Motors”, has announced attractive discount sales. The Outlet Head has fixed the discount rates of the Cars based on the years of usage and condition of a car.
Akash, a teenager wished to buy an economical pre-owned Car of any famous brand but that was in pretty good condition. Having known about the discount offers at “Silicon Motors”, he visited the showroom to see if he could get convincing Models. After glimpsing through the Cars in the display, Akash wanted to calculate the discount price for those Cars that he was interested in so that he could conclude his selection.
Write a C++ program to calculate the discount price of the Cars of his choice.
Strictly adhere to the Object-Oriented specifications given in the problem statement. All class names, member variable names, and function names should be the same as specified in the problem statement.
Consider a class called Car which has the following private variables.
Datatype | Variable |
string | model |
double | price |
string | condition |
int | year |
Include the following overloading function in the class Car.
Function Name | Description |
void price(string model, double price) | This function displays the model and actual price of the car. |
void price(string model, double price, string condition, int year) | This function is used to calculate the price after the discount of the car based on the years of usage and condition of the car. |
If the years of usage is less than 3 years and the car condition is good the discount will be 20%.
If the years of usage is greater than 5 years and the car condition is good, then the discount will be 40%.
If the years of usage is greater than 5 years and the car condition is moderate, then the discount will be 50%.
If the years of usage is greater than 5 years and the car condition is poor, then the discount will be 60%.
Input and Output Format:
All double values should be displayed with two decimal places.
Refer sample input and output for formatting specifications.
[All text in bold corresponds to input and the rest corresponds to the output]
Sample Input and Output 1:
Enter the model of the car
verna
Enter the actual price of the car
150000
Enter the years of usage of the car
2
Enter the condition of the car
good
Car Details
Model : Verna
Actual Price : 150000
Price after discount : 120000
-----------End Of Question-----------
TEMPLATE BELOW
car.cpp
using namespace std; class Car public: void price(string model,double price,string condition,int year){ |
Step by step
Solved in 4 steps with 2 images