Question: C++ here, is it possible i can get help with this #include #include #include // std::string, std::to_string, std::fixed #include // std::setprecision using namespace std; class
C++ here, is it possible i can get help with this
#include
#include
#include
#include
using namespace std;
class Car
{
private:
float mileage; // Total cumulative mileage traveled by the Car
float gasInTank; // Total gas in gallons held in the Car's tank
float milesPerGallon; // Car's gas mileage in miles per gallon (mpg)
float tripMileage; // Mileage traveled by Car on its last trip
float tripGasConsumed; // Gallons of gas consumed by Car during last trip
public:
// Constructors
/**
* Car instance with an initial milesPerGallon (mpg).
* The other parameters are explicitly set to 0.0;
*/
Car(float mpg) {
milesPerGallon = mpg;
mileage = 0.0;
gasInTank = 0.0;
tripMileage = 0.0;
tripGasConsumed = 0.0;
}
// Constructor declared
Car(float mileage, float gasInTank, float milesPerGallon);
// Getters
float getMileage() {return mileage;}
float getGasInTank() {return gasInTank;}
float getMilesPerGallon() {return milesPerGallon;}
float getTripMileage() {return tripMileage;}
float getTripGasConsumed() {return tripGasConsumed;}
// Setters
void setMileage(double mileage){this->mileage = mileage;}
void setGasInTank(double gasInTank);
void setMilesPerGallon(double milesPerGallon);
void setTripMileage(double tripMileage);
void setTripGasConsumed(double tripGasConsumed) {this->tripGasConsumed = tripGasConsumed;}
// DO NOT EDIT OR CHANGE THIS METHOD
void display() // Used to display test case results
{
cout << fixed;
cout << setprecision(2);
cout << "Mileage: " << this->getMileage();
cout << " / Gas in tank: " << this->getGasInTank();
cout << " / MPG: " << this->getMilesPerGallon();
cout << " / Trip Mileage: " << this->getTripMileage();
cout << " / Trip Gas: " << this->getTripGasConsumed() << endl;
}
// Instance methods provided
//Add the given gallons of gas to the target Car
void pumpGas(float gallons) { gasInTank += gallons;}
//Resets both the trip mileage and trip gas consumed
//to 0 to start measuring the next (new) trip.
void resetTrip() {
tripMileage = 0;
tripGasConsumed = 0;
}
// Methods declared
Car mostFilled(Car &c2);
float fillToDistance(float miles, float gasCost);
void fillPayment(float moneyPaid, float gasCost);
float sellCar();
};
int main(){
cout << "HELLO FROM CAR CLASS" << endl;
cout << "---TEST CASES BELOW---" << endl;
//Example of Test Cases
//Exercise #5
Car Car51 = Car(30);
Car51.setMileage(800);
cout << Car51.sellCar() << endl;
//Expected Result
cout << "15000.00" << endl;
return 0;
//excersie #6
Car Car61 = Car(30);
Car61.setTripMileage(1200);
Car61.setGasInTank(15);
Car61.setMilesPerGallon(25);
Car61.display();
//expected result
Mileage: 0.00 / Gas in tank: 15.00 / MPG: 25.00 / Trip Mileage: 1200.00 / Trip Gas: 0.00
}
/*********************************************************************
* EXERCISE #5
*
* Return the amount of selling price of the target car by mileage.
* If the mileage of the car is lower than 1000 miles it would sell at
* $15,000. If the mileage of the car is 1000 miles or greater and less
* than 5000 miles it would sell at $10,000. If the mileage of the car
* is 5000 miles or greater it would sell at $5,000.
*/
float Car::sellCar(){
// TODO -- YOUR CODE HERE
return 0; //Dummy Return
}
/*********************************************************************
* EXERCISE #6 BONUS!!
*
* Define the setters for tripMileage, gasInTank, and milesPerGallon
*/
// TODO -- YOUR CODE HERE
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
