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
Write a program that reads a list of integers, and outputs those integers in reverse. The input begins with an integer indicatin
kkurt [141]

Answer:

The program to this question as follows:

Program:

#include <stdio.h> //header file.

int main() //main method.

{

const int size= 20; //define variable.

int a[size]; //define array

int i, n; //define variable

printf("Enter number of elements :"); //message.

scanf("%d", &n);//input size of array.

printf("Enter array elements :"); //message

for (i = 0; i < n; ++i) //loop

{

scanf("%d",&a[i]); //input array elements by user.

}

printf("Reverse order :\n");

for (i = 0; i < n; ++i) //loop

{

printf("%d ",a[n-i-1]); //print elements in reverse order.

}

return 0;

}

Output:

Enter number of elements :5

Enter array elements :5

4

3

2

1

Reverse order :

1 2 3 4 5  

Explanation:

The description of the above program as follows:

  • In the program firstly we include the header file and define a method that is "main method" in the method we define variables that are "size, n, i, and a[]".  The size variable is used to make a variable constant that means its value will not change in the program. We pass the size variable value to the array and use i variable for loop.
  • We use variable n and a[] for user inputs. In n variable, we input a number of elements to be inserted into an array and a[] we insert all array elements to insert these elements we use for loop.
  • Then we define another for loop in this loop we print all array elements in reverse order.
3 0
3 years ago
Science Help
pishuonlain [190]
C. as carbon dioxide
5 0
3 years ago
One purpose of the dual ignition system on an aircraft engine is to provide for?
Gnom [1K]
It is done to provide for better engine performance. It is important for two main reasons. One is that if one ignition system fails the other can for a time take care of it and hold its ground until you land or fix it. Another is that it is used for more efficient consumption of fuel and air which makes the engine work better.
7 0
3 years ago
Read 2 more answers
Write a program that prompts the user for a measurement inmeters and then converts it into miles, feet, and inches.
zubka84 [21]

Answer:

Program for measurement in meters and then converts it into miles, feet, and inches:

#include<iostream.h>

#include<conio.h>

void main()

{  float meter, mile, feet, inches;

 cout<<"enter meters";

 cin>>meters";

 feet=meter×3.2808;

 mile= meter×0.000621371;

 inches= meter×39.3701;

cout<<"Value of"<<meter<<"meter"<<"in feet is"<<feet<<"feet":

cout<<"Value of"<<meter<<"meter"<<"in mile is"<<mile<<"mile";

cout<<"Value of"<<meter<<"meter"<<"in inches is"<<inches<<"inches";

getch();

}

8 0
3 years ago
If your DTP document contains watermarks on every page, where can you place them?
QveST [7]

Answer:

<h3>You can place watermarks and other recurring elements on a DTP document by following the points below:</h3><h3 />
  • Open the DTP document on which watermark is to be placed.
  • Click on Page Layout tab
  • Locate the Page Background group and click it.
  • Select the Watermark Option and then select Custom watermark.
  • A box will open when you click the Text Watermark.
  • Type the text you want and click on Insert.
  • All other changes can be done using options.

<h3>I hope it will help you!</h3>

6 0
3 years ago
Other questions:
  • What is the slogan of the sociological school of criticism ?​
    9·1 answer
  • How can you make a circle in JavaScript? Thank you!
    9·1 answer
  • TIFF is the default file format for most digital cameras. State True or False.
    13·1 answer
  • A modern version of the BIOS firmware is called?
    12·1 answer
  • Hi, please help me complete my Database Development 2 hw by completing what should been done from the document and show the code
    11·1 answer
  • 4.12 LAB: Using math methods Given three floating-point numbers x, y, and z, output x to the power of z, x to the power of (y to
    10·1 answer
  • Which of the following is constantly changing and advancing?
    11·1 answer
  • What videos do you think we should make next?
    9·1 answer
  • How do you save a document in a format so that any reader can view it?
    5·1 answer
  • before you start researching fleet management software, your first task is to clearly define the problem. this will help guide y
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!