Homework function assistance

I am new to C++ and am taking the course online. Can somebody help me revise my work so I can resubmit it.

Instructor Comment:

What is the point of creating and calling a function if you don't use the results?

gallons = convert_liters_to_gallons(liters);
miles_per_gallon = miles/(liters * GALLONS_PER_LITER);


Place the calculations inside the functions
correct and re-submit

Assignment:
A liter is 0.264179 gallons. Write a program that will read in the number of liters of gasoline consumed by the user's car and the number of of miles traveled by the car, and will then output the number of miles per gallon the car gets. Your program should allow the user to repeat this calculation using a loop. Your program should use a globally defined constant for the number of liters per gallon.

You may

1. Write two functions in addition to main(). Write one function that calculates the gallons from the liters and another function that calculates the miles per gallon from the miles and the gallons.

OR

2. Write one function, in addition to main(), that calculates the miles per gallon from the miles and the liters. It would convert the liters to gallons internally.



//Nick Valladares
//Assignment: 3

#include<iostream>

using namespace std;

// constant definition
const double GALLONS_PER_LITER = 0.264179;

// Function Decleration
double convert_liters_to_gallons(double liters);



int main()


{
double miles;
double liters;
double gallons;
double miles_per_gallon;
char again;

// start loop
do
{
cout << "Enter the liters of gas used on the trip:";
cin >> liters;

cout << "Ener the miles traveled on the trip:";
cin >> miles;


// function call

gallons = convert_liters_to_gallons(liters);
miles_per_gallon = miles/(liters * GALLONS_PER_LITER);

// display output

cout << "\nWhen you use" << liters
<< " liters of gas your car gets" << miles_per_gallon << ",\n";

cout << "miles per gallon "
<< endl;

cout << "\nDo you want to do another item (Y/N)? ";
cin >> again;


// end loop
}while (again == 'Y' || again == 'y');


return 0;
}

// function definition

double convert_liters_to_gallons(double liters)

{
return liters * GALLONS_PER_LITER;

}
It seems pretty self-explanatory...look at the lines they gave you and explain to me what you are doing.
You obtained gallons using the function return value,but you didnt output this value.Maybe this is what your instructor said.
Ok thanks guys I am new at this and trying to teach myself the language.
Topic archived. No new replies allowed.