Write the header file Car.h for the Car class. The Car class has three data memb
ID: 3695696 • Letter: W
Question
Write the header file Car.h for the Car class. The Car class has three data members: miles_per_gallon (double), fuel (double), and model (string). The Car class has a constructor that initializes each data member. The Car class has four additional member functions: get_model : no parameters, returns model drive : double miles parameter, returns nothing add_fuel : double gallons parameter, returns nothing low_on_fuel : no parameters, returns true or false Do not provide the implementation of the member functions.Explanation / Answer
Program :-
------------------
public class Car {
double miles_per_gallon;
double fuel;
String model;
public Car(double miles_per_gallon, double fuel, String model) {
super();
this.miles_per_gallon = miles_per_gallon;
this.fuel = fuel;
this.model = model;
}
Model get_model(){
return model;
}
void drive(double miles){
}
void add_fuel(double gallons){
}
boolean low_on_fuel(){
return false;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.