"Write a complete program based on the functions in question 5 and 6 above. Add another function called print_okay that tells the user that he or she will it to the next gas station. Convert the if structure to an if / else and include the call to the print_okay function in the else clause.
Okay.. what was in the questions above is:
void print_warning()
{
cout %26lt;%26lt; "WARNING: Calculations indicate that you will run\n";
cout %26lt;%26lt; "out of fuel before the next available gas station.\n";
And
int main()
{
float miles_remaining, fuel_remaining, mpg, fuel_miles;
cout %26lt;%26lt; "How many miles are you from the next gas station? ";
cin %26gt;%26gt; miles_remaining;
cout %26lt;%26lt; "How much fuel do you have left (in gallons) ? ";
cin %26gt;%26gt; fuel_remaining;
cout %26lt;%26lt; "What is your average miles to the gallon? ";
cin %26gt;%26gt; mpg;
fuel_miles = fuel_remaining * mpg;
Help with this C++ Program?
First of all--do your own homework, but you need a function like this:
void print_okay()
{
cout %26lt;%26lt; "Calculations indicate that you will make it to the next gas station" %26lt;%26lt; endl;
}
and wherever the if statement is in the main function, you need an else after it that calls print_okay();
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment