Question: In c++, write a class named Car that has the following member variables: yearModel A int that holds the cars year model make A string

In c++, write a class named Car that has the following member variables:

yearModel A int that holds the cars year model

make A string that holds the make of the car

speed an int that holds the cars current speed.

In addition the calss should have the following constructor and other member functions.

constructor. The constructor should accept the cars year and model and make as arguments. These values should be assaigned to the objects yearModel and make member variables. The constructor should also be assign 0 to the speed member variables.

Accessor. appropirate accessor functions to get the values stored in an objects yearModel, make, and speed member variables

accelerate. The accelerate function shold add 5 to the speed member variable each time it is called.

brake. The brake function should subtract 5 from the speed member variable each time it is called.

Demostrate the class in a program that creates a car object, and then calls the accelerate function five times. After each call to the accelerate function, get the current speed of the car and display it. Then, call the brake function five times. After each call to the brake function, get the current speed of the car and display it.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!