Westonci.ca is the premier destination for reliable answers to your questions, brought to you by a community of experts. Explore thousands of questions and answers from a knowledgeable community of experts on our user-friendly platform. Get detailed and accurate answers to your questions from a dedicated community of experts on our Q&A platform.
Sagot :
The C++ program to show and complete the Car class (in files Car.h and Car.cpp) with member functions to set and get the purchase price of a car is:
Car.h
#ifndef CARH
#define CARH
class Car{
private:
int modelYear;
int purchasePrice;
int currentValue;
public:
void SetModelYear(int userYear);
int GetModelYear() const;
void SetPurchasePrice(int purchasePrice);
int GetPurchasePrice() const;
void CalcCurrentValue(int currentYear);
void PrintInfo();
};
#endif // CARH
Car.cpp
#include<iostream>
#include<math.h>
#include "Car.h"
using namespace std;
void Car::SetModelYear(int userYear){
modelYear=userYear;
}
int Car::GetModelYear() const{
return modelYear;
}
void Car::SetPurchasePrice(int userPrice){
purchasePrice = userPrice;
}
int Car::GetPurchasePrice() const{
return purchasePrice;
}
void Car::CalcCurrentValue(int currentYear){
double depreciationRate = 0.15;
int carAge = currentYear- modelYear;
currentValue = (int)round(purchasePrice*pow((1-depreciationRate),carAge));
}
void Car::PrintInfo(){
cout<<"Car's information:\n";
cout<<"\t\tModel Year : "<<GetModelYear();
cout<<"\n\t\tPurchase price: "<<GetPurchasePrice();
cout<<"\n\t\tCurrentValue: "<<currentValue;
}
Read more about C++ programs here:
https://brainly.com/question/20339175
#SPJ1
We hope you found this helpful. Feel free to come back anytime for more accurate answers and updated information. We appreciate your visit. Our platform is always here to offer accurate and reliable answers. Return anytime. Thank you for choosing Westonci.ca as your information source. We look forward to your next visit.