Question: Given main ( ) , complete the Car class ( in files Car.h and Car.cpp ) with member functions to set and get the purchase
Given main complete the Car class in files Car.h and Car.cpp with member functions to set and get the purchase price of a car SetPurchasePrice GetPurchasePrice and to output the car's information PrintInfo
Ex: If the input is:
where is the car's model year, is the purchase price, and is the current year, the output is:
Car's information:
Model year:
Purchase price:
Current value:
Note: printInfo should use three spaces for indentation.
main.cppCan not be changed
#include
#include "Car.h
using namespace std;
int main
int userYear;
int userPrice;
int userCurrentYear;
Car myCar;
cin userYear;
cin userPrice;
cin userCurrentYear;
myCar.SetModelYearuserYear;
myCar.SetPurchasePriceuserPrice;
myCar.CalcCurrentValueuserCurrentYear;
myCar.PrintInfo;
return ;
Car.cpp
#include
#include
#include "Car.h
using namespace std;
void Car::SetModelYearint userYear
modelYear userYear;
int Car::GetModelYear const
return modelYear;
TODO: Implement SetPurchasePrice function
TODO: Implement GetPurchasePrice function
void Car::CalcCurrentValueint currentYear
double depreciationRate ;
int carAge currentYear modelYear;
Car depreciation formula
currentValue int
roundpurchasePrice pow depreciationRate carAge;
TODO: Implement PrintInfo function to output modelYear, purchasePrice, and
currentValue
Car.h
#ifndef CARH
#define CARH
class Car
private:
int modelYear;
TODO: Declare purchasePrice member int
int currentValue;
public:
void SetModelYearint userYear;
int GetModelYear const;
TODO: Declare SetPurchasePrice function
TODO: Declare GetPurchasePrice function
void CalcCurrentValueint currentYear;
TODO: Declare PrintInfo method to output modelYear, purchasePrice, and
currentValue
;
#endif
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
