Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Can you help me complete #include #include #include mileage.h using namespace std; int main ( ) { / / Declare and initialize variables double
Can you help me complete
#include
#include
#include "mileage.h
using namespace std;
int main
Declare and initialize variables
double miles ;
double gallons ;
Limit decimal display to two decimal places.
cout fixed setprecision;
Retrieve data from user and validate data entered.
cout "Enter the miles driven: endl;
cin miles;
while miles
cout "Incorrect entry.
Enter a number"
greater than zero." endl;
cin miles;
cout "Enter the gallons used: endl;
cin gallons;
while gallons
cout "Incorrect entry.
Enter a number"
greater than zero." endl;
cin gallons;
Create copy of mileage class
mileage myMiles miles, gallons ;
Display results for user
cout "Your car gets myMiles.getMPG
milespergallon." endl;
#include "mileage.h
mileage::mileagedouble miles, double gallons
setMilesmiles;
setGallonsgallons;
void mileage::setMilesdouble miles
thismiles miles;
void mileage::setGallonsdouble gallons
thisgallons gallons;
double mileage::getMiles
return miles;
double mileage::getGallons
return gallons;
double mileage::getMPG
Do not directly access the private variables of the class.
Use the get methods.
return getMiles getGallons;
#pragma once
class mileage
private:
double miles;
double gallons;
public:
mileage double, double ;
void setMilesdouble;
void setGallonsdouble;
double getMiles;
double getGallons;
double getMPG;
;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started