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

The Class ‘Car’ is missing the implementation of the constructor. Create the mis

ID: 3580493 • Letter: T

Question

The Class ‘Car’ is missing the implementation of the constructor. Create the missing constructor: Here is the ‘header file’:

1. #ifndef MID RM2 CAR H TE 2. #define MID RM2 CAR H TEI 3. #include CCtype 4. #include fstream 5. #include 7. #include 8. #include g. using namespace std, 10. Class Car 11 12. public: 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) 22. 23. drive the number of miles passed in 24. up the miles driven for the car and the amount date 25. of gas used. 28 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 36. private: 38. Data members to s 39. 40. double mpg, 41. double miles driven 0, 42. double gas amount 0, 43. 44. #endif TEI CAR H RM2

Explanation / Answer

Here is the constructor implementation for you:

#include "Car.cpp"

//Constructor
Car::Car(double efficiency) {
   mpg = efficiency;
   miles_driven = gas_amount = 0;
}


//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;
}


}