The Class ‘Car’ is missing the implementation of the mutator, drive. Create the
ID: 3580485 • Letter: T
Question
The Class ‘Car’ is missing the implementation of the mutator, drive. Create the missing mutator: Here is the ‘header file’:
1. #ifndef TERM CAR H MID 2. #define MID RM2 CAR H TEI 3. #include CCtype 4. #include fstream 5. #include iostream> 6. #include iomanip> 7. #include 8. #include g. using namespace std, 10. Class Car 12. public: 13. 14. Constructor for a car object. The efficiency in mpg is 15. passed to the constructor. 17. Car(double efficiency), 19. add 'amt' of gas in gallons 21. void add gas(double amt) 23. drive the number of miles passed in 24. up the miles driven for the car and the amount date 25. of gas used. 26. void drive double miles) 27. 28. 2g. Return the amount of gas still in this car 30. 31. double get gas level const, 33. Return the miles driven by this car 34. 35. double get miles driven() const, 30. private. 38. Data members to store... 39. 40. double mpg, 41. double miles driven 0, 42. double gas amount 0, 43. 44. #endif TEI CAR H RM2Explanation / Answer
Here is the implementation for Car for the method dirve():
#include "Car.cpp"
//Constructor
//add gas
void Car::add_gas(double amt) {
gas_amount += amt;
}
//get_gas_level
//get miles driven
double Car::get_miles_driven() const {
return miles_driven;
}
//drive
void Car::drive(double miles) {
miles_driven += miles;
gas_amount -= miles/mpg;
}
}