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
One critique of determining the effectiveness of the psychodynamic perspective is that its theories are too vague to test. t/f
Feliz [49]
TRUE

Psychodynamic theories are usually too vague to allow a clear scientific test. Modest support for central psychodynamic hypotheses has been provided by Empirical studies. Critics have in the past disputed very many aspects of psychoanalysis including whether it is indeed a science or not. However much this is so, psychoanalysis is a great idea in personality that should never be overlooked.






3 0
4 years ago
Read 2 more answers
The following code segment is a count-controlled loop going from 1 to 5. At each iteration, the loop counter is either printed o
quester [9]

Answer:

True.

Explanation:

For all the count values, if Ranfun() returns true then all the values of count would be printed. Then the sequence of count values printed would be 1 2 3 4 5. Also for all the values of count if Ranfun() returns false then all the values would be enqueued. When we try to dequeue elements from queue we would get them in the same order of their entry into the queue. Thus, the sequence would be 1 2 3 4 5. Hence, we can say that this output sequence is possible. TRUE.

4 0
3 years ago
Describe the three essential characteristics of an object fromthe perspective of object oriented paradigm.
erastovalidia [21]

Answer:

Explained

Explanation:

The three characteristics of an object

Encapsulation: It is the process of capturing data and securing it for safety from the outside interfaces. Binding data and operations of data into a single unit.

Inheritance: This is the process by which a class can be derived from the base class, with all features of base class and some of its own. This increases data reusability.

Abstraction: The ability to represent data at very basic level without showing the details of it is called abstraction.

3 0
3 years ago
What is the portrait mode ?
Effectus [21]
On a camera portrait mode is when the camera is vertical.
7 0
3 years ago
For most people, the most effective way to save is:
oksian1 [2.3K]
I would say it's by creating a spending budget. 
3 0
3 years ago
Other questions:
  • _____ is an information-analysis tool that involves the automated discovery of patterns and relationships in a data warehouse.
    12·1 answer
  • What is the most recognized and widely used database of published nursing practice literature?
    15·1 answer
  • What are the data types used in C programming with examples
    5·1 answer
  • Joe, a user, has just installed his first home wireless router. Which of the following tasks should be considered to help secure
    8·1 answer
  • TRUE OR FALSE! HELP!!
    13·1 answer
  • What’s the answer to this question?
    15·1 answer
  • What can you find the under the privacy policy section of a shopping website?
    12·1 answer
  • A location in memory which stores a value, the value can change as the program is running is
    12·1 answer
  • Which three statements are true of lossless compression?
    6·1 answer
  • Which of the following was the first computer-animated film to win animated film to win an academy award?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!