1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Nataliya [291]
2 years ago
6

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 c

ar (SetPurchasePrice(), GetPurchasePrice()), and to output the car's information (PrintInfo()). Ex: If the input is: 2011 18000 2018 where 2011 is the car's model year, 18000 is the purchase price, and 2018 is the current year, the output is: Car's information: Model year: 2011 Purchase price: 18000 Current value: 5770
Computers and Technology
1 answer:
Snezhnost [94]2 years ago
6 0

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:

<h3>Car.h</h3>

#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

<h3>Car.cpp</h3>

#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:

brainly.com/question/20339175

#SPJ1

You might be interested in
Which file format produces a lock-down version of an access database? accdb accdb-be accde accdb-e
jek_recluse [69]

The file format that produces a lock-down version of an access database is called; ACCDE

<h3>How to Identify Access Database?</h3>

ACCDB files are the default Microsoft Access database format in Access 2007 and later versions while the ACCDE format is a read-only, compressed version.

Now, the file format that produces a lock down version of an access database is called ACCDE file which is a Microsoft Access Execute Only Database file used to protect an ACCDB file.

Read more about Access Database at; brainly.com/question/9745438

#SPJ1

8 0
2 years ago
Which logic gate produces an output of 1 only if both its inputs are 0
Anettt [7]

0=false

1=true

false + false = true

0+0=1

+ operator = and function

AND GATE

8 0
3 years ago
Read 2 more answers
What field would you use to store a value from another table?
Levart [38]

Answer:

A. Lookup

Explanation:

You would use the Lookup field to store a value from another table.

7 0
3 years ago
If you do not want the border style to carry forward each time the enter key is pressed, you need to ____.
ANEK [815]
Hello <span>Endermss2118 </span>

Answer: If you do not want the border style to carry forward each time the enter key is pressed, you need to Clear formatting


Hope This Helps
-Chris
8 0
3 years ago
ABC Enterprises has three employees who work in the same building. The type of network they need is a _____. LAN MAN STAN WAN
algol [13]
The type of network they need is LAN
8 0
3 years ago
Read 2 more answers
Other questions:
  • Which is an example of an input device?
    15·2 answers
  • 1. [2 points] Write a function to compute the volume of a sphere, given its radius. 2. [2 points] Write a recursive function to
    7·1 answer
  • Remember for a moment a recent trip you have made to the grocery store to pick up a few items. What pieces of data did the Point
    15·1 answer
  • While the zyLab platform can be used without training, a bit of training may help some students avoid common issues. The assignm
    6·1 answer
  • Please conduct some research and find an article on Security Threats and please provide link of the article.
    5·1 answer
  • Which routing protocol does an exterior router use to collect data to build its routing tables?
    8·1 answer
  • How would you copy all files from a remote directory into your LOCAL home folder.
    6·1 answer
  • Write a program to display MPH (Miles per Hour). Create a function to calculate the MPH. Ask the user for the number of miles dr
    11·1 answer
  • F
    9·1 answer
  • Have some points part 6<br>anyone know how to change my username?​
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!