Question: In c + + write a class named Car that has the following member variab les: yearModel an int that holds the car s year

In c++ write a class named Car that has the following member variab les:
yearModelan int that holds the cars year model
makea string that holds the make of the car
speedan int that holds the cars current speed In addition, the class should have the following constructor and other member
functions:
ConstructorThe constructor should accept the cars year model and make as argu
ments. These values should be assigned to the objects yearModel and make member
variables. The constructor should also assign 0 to the speed member variables.
Accessorappropriate accessor functions to get the values stored in an objects
yearModel, make, and speed member variables
accelerateThe accelerate function should add 5 to the speed member vari
able each time it is called.
brakeThe brake function should subtract 5 from the speed member variable
each time it is called.
Demonstrate the class in a program that creates a Car object, 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!