Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a class named Car that has the followingmember variables: yearModel . An i

ID: 3613689 • Letter: W

Question

Write a class named Car that has the followingmember variables:

      yearModel.An int that holds the car’s year model.

•    make. A stringthat holds the make of the car.

•    speed.An int that holds the car’s current speed.

In addition, the class should have the followingconstructor and other member functions.

•   Constructor. Theconstructor should accept the car’s year model and makeas

      arguments. Thesevalues should be assigned to the object’s yearModel andmake

      member variables.The constructor should also assign 0 to the speed member

      variables.

•   Accessor. Appropriateaccessor functions to get the values stored in anobject’s

      yearModel, make, andspeed member variables.

•   brake. The brakefunction should subtract 5 from the speed member variable

      each time it iscalled.

Demonstrate the class in a program thatcreates a Car object, and then calls the

accelerate function five times. After each call tothe accelerate function, get the

current speed of the car and display it. Then, callthe brake function five times. After

each call to the brake function, get the currentspeed of the car and display it.

Explanation / Answer

please rate - thanks #include #include using namespace std; class Car { public: Car(string m,int year) {yearModel = year;    make = m;    speed = 0;    } void accelerate()    {speed += 5; }     void brake()     {speed -= 5; } int getSpeed()     {return speed; } string getMake()     {return make; } int getYear()     {return yearModel; }   private:    int yearModel;      string make;        int speed;      }; int main() {int i; Car a("Toyota",2002); cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote