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
A file containing user information which is transmitted from an online server and attached to your web browser and stored on you
rewona [7]
The answer is: <span>Cookie</span>
5 0
3 years ago
How do i fix a name split in python
Goshia [24]

Explanation:

its impossible

name error python

3 0
3 years ago
There are 10 girls and 8 boys at a party. A cartoonist want to sketch a picture of each boy with each girl. How many sketches ar
kykrilka [37]
80 sketches will be required. It’s just multiplication. Let x=boys and y=girls. If x=8 and y=10, then one boy has to be with one girl. In total 1 boy will be with 10 girls, so that’s 10 sketches. You do the same for boy #2 and so on. It adds up to 80.
3 0
3 years ago
Write a Python program to print the multiplication table of 4​
garri49 [273]

Answer:

multiplier = 0

while multiplier <= 12:

   print(f'4 times {multiplier} = ' + str(4 * multiplier))

   multiplier += 1

Explanation:

The multiplier is just a variable

while the variable is equal to or less than 12, the program will print "4 times (multiplier value) = (4 times the multiplier value)"

the multiplier value then is increased each time the while loop is completed(which is 12 times)

And when the multiplier value is equal to 12, the program will stop, hope this helps! A simpler version would just be

multiplier = 0

while multiplier <= 12:

   print(4 * multiplier)

   multiplier += 1

8 0
3 years ago
How can i add a lifeline on my scratch game
frutty [35]

Answer: Click lifeline

Explanation: All you have to do when you get on the game is just click that button on the top right.

7 0
3 years ago
Read 2 more answers
Other questions:
  • Your supervisor has asked you to help with the orientation of three new office employees. Topics you're asked to present include
    9·1 answer
  • Sorry to bother you guys but for some reason it wont let me comment. How can i fix this?
    5·2 answers
  • Write a full class definition for a class named Averager, and containing the following members: An data member named sum of type
    7·1 answer
  • A constructor can be overloaded with more than one function which has the same name but with what two different things
    7·1 answer
  • 7. Question
    12·1 answer
  • Write a small program that takes in two numbers from the user. Using an if statement and an else statement, compare them and tel
    12·1 answer
  • few toffees were distributed among oriya , piyush and payal . priya got 3/8 , piyush and payal 1/8 and 1/2 of total toffees resp
    5·1 answer
  • How does Virus transfer from one computer to<br>another computer?​
    6·1 answer
  • Which website citation is correctly formatted according to MLA standards?
    11·2 answers
  • Virtual reality simulates a three-dimensional environment with which users can explore and interact. True or false?.
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!