Question: Define a class named Car that has 3 private variables: A string named model, an integer named nbrOfDoors, and a double named mpg. The Car
Define a class named Car that has 3 private variables: A string named model, an integer named nbrOfDoors, and a double named mpg. The Car class has public getters and setters for the above private variables. The Car class also has a constructor to populate the above variables with default values: Model: Escape, Doors: 4, MPG: 32
In the main function, instantiate a Car object without any arguments. Display your car object. Declare a Car pointer, and point it to your Car object. Get info from the user to change the details of your car.
Use your Car pointer to populate your car object with the new details. Use your Car pointer to display the new details of your car. Declare any variables you need in the main function.
Sample output:
Escape has 4 doors and gets 32 miles per gallon
Enter new car info
Model: Edge
Number of doors: 5
MPG: 28
Edge has 5 doors and gets 28 miles per gallon
C++
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
