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 following member varibles: YEAR: an int tha

ID: 3630561 • Letter: W

Question

write a class named car that has the following member varibles:
YEAR: an int that holds the car's model year
MAKE: a string that holds the make of the car
SPEED: an int that holds the car's current speed
in addidtion the class should include:
constructor that should accept the car's year and make as arguments and assign these values to the objects year and make member varibles. The constructor should initialize the speed member varible to 0.
Appropriate accessor functions should be created to allow values to be retrieved from an objects year,make,and speed member varibles.
The accelerate function should add 5 to the speed member varible each time called. The Brake fuction should subtract 5. Demonstrate the class and then call accelerate function 5 times. After each call to accelerate function, get the current speed of car and display it. Then, call the brake fuction 5 times, and display. For this project store class delarations and member functions in their own seperate files, place main in another file.

Explanation / Answer

#include #include #include using namespace std; class Car { private: int YearModel; int Speed; string Make; public: Car(int, string, int); string getMake(); int getModel(); int getSpeed(); void Accelerate(); void Brake(); }; Car::Car(int YearofModel, string Makeby, int Spd) { YearModel = YearofModel; Make = Makeby; Speed = Spd; } //To get who makes the car. string Car::getMake() { return Make; } //To get the year of the car. int Car::getModel() { return YearModel; } //To holds the car actual speed. int Car::getSpeed() { return Speed; } //To increase speed by 5. void Car::Accelerate() { Speed = Speed +5; } //To drop the speed of the car by 5. void Car::Brake() { Speed = Speed -5; } int main() { int Speed = 0; //Start Cars speed at zero. int index; int total=0; cout