trying to debug a second program and having trouble

displays the miles per gallon

#include

using namespace std;

//function prototypes
float getMiles();
float getNumGallons();
int calcMpg(float, float);

int main()
{

float miles = 0.0;
float gallons = 0.0;
float milesPerGal = 0.0;

//enter input items
miles = getMiles();
gallons = getNumGallons();

//calculate miles per gallon
milesPerGal = calcMpg(miles, gallons);

//display output item
cout << fixed;
cout.precision(1);
cout << "Miles per gallon: " << milesPerGal << endl;

return 0;
} //end of main function

//*****program-defined functions*****
float getMiles()
{
cout << "Enter the number of miles: ";
cin >> numMiles;
return numMiles;
} //end of getMiles function

float getNumGallons()
{
float numGallons = 0.0;
cout << "Enter number of gallons: ";
cin >> numGallons;
return numGallons;
} //end of getNumGallons function

float calcMilePG(float distance, float galUsed)
{
float dist / galUsed;
cout << "Enter distance / galUsed: ";
return distance / galUsed;
} //end of calcMpg function

Comments

  • : displays the miles per gallon
    :
    : #include
    :
    : using namespace std;
    :
    : //function prototypes
    : float getMiles();
    : float getNumGallons();
    : int calcMpg(float, float);
    :
    : int main()
    : {
    :
    : float miles = 0.0;
    : float gallons = 0.0;
    : float milesPerGal = 0.0;
    :
    : //enter input items
    : miles = getMiles();
    : gallons = getNumGallons();
    :
    : //calculate miles per gallon
    : milesPerGal = calcMpg(miles, gallons);
    :
    : //display output item
    : cout << fixed;
    : cout.precision(1);
    : cout << "Miles per gallon: " << milesPerGal << endl;
    :
    : return 0;
    : } //end of main function
    :
    : //*****program-defined functions*****
    : float getMiles()
    : {
    : cout << "Enter the number of miles: ";
    : cin >> numMiles;
    : return numMiles;
    : } //end of getMiles function
    :
    : float getNumGallons()
    : {
    : float numGallons = 0.0;
    : cout << "Enter number of gallons: ";
    : cin >> numGallons;
    : return numGallons;
    : } //end of getNumGallons function
    :
    : float calcMilePG(float distance, float galUsed)
    : {
    : float dist / galUsed;
    : cout << "Enter distance / galUsed: ";
    : return distance / galUsed;
    : } //end of calcMpg function
    :
    :

    I replied to this message on another message board!

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion