Question: Write a C++ program which has a main-driver and a class named Auto that has the following member variables: ownerName . A string that holds

Write a C++ program which has a main-driver and a class named Auto that has the following member variables: ownerName . A string that holds the Auto owner's full name like "John Doe". yearModel . An int that holds the Autos year model. make . A string that holds the make of the Auto. speed . An int that holds the Autos current speed. In addition, the class should have the following member functions: Constructor. The constructor should accept the Autos year, model, and make as arguments. These values should be assigned to the objects ownerName, yearModel, and make member variables. The constructor should also assign 0 to the speed member variables. Accessor. Appropriate accessor functions to get the values stored in an objects ownerName, 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. Demonstrate the class in a program that has a main() function which creates an Auto object, and then loops (like a shell) and in each loop, asks the user to press a letter (char) from the menu: "Press 'a' to accelerate, 'b' to brake/decelerate. Which do you choose?" repeatedly. After each call to the accelerate function, get the current speed of the car and display it. After each call to the brake function, get the current speed of the car and display it. If the car stops, print: "You have parked." Don't let the speed become negative. If the speed exceeds 55, print: "You get a ticket for speeding." If the speed exceeds 70, print: "Go directly to Jail. Do not pass go; do not collect $200." The program stops when you park, go to jail, or 8 times through the loop. The program should simulate the behavior of an automobile and then on the last step display the data for the Auto each worker on the screen and their weekly pay.

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!