Question: C++ Programming. Car Class Write a class named Car that has the following member variables (often called instance variables): yearModel. An int that holds the

C++ Programming.

Car Class

Write a class named Car that has the following member variables (often called instance variables):

yearModel. An 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 class should have the following constructor and other member functions.

Constructor. The constructor should accept the cars year model and make as arguments. These values should be assigned to the objects yearModel and make member variables. The constructor should also assign 0 to the speed member variable. Accessor. Appropriate accessor functions to get the values stored in an objects yearModel, make, and speed member variables. accelerate. The accelerate function should 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. DO NOT allow the vehicle speed to reach a negative number.

Demonstrate 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 six 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!