Homework Solution: A car with a 20 gallon gas tank averages 23.5 miles per gallon when driven in town and 28.9 miles per gallon when driven on the highway….

    A car with a 20 gallon gas tank averages 23.5 miles per gallon when driven in town and 28.9 miles per gallon when driven on the highway. Write a C++ program that calculates and displays the distance the car can travel on one tank of gas when driven in town and when driven on the highway.

    Expert Answer

     
    Hi, Below is the C++ code for the question-

    A car with a 20 gallon fog tank averages 23.5 miles per gallon when driven in town and 28.9 miles per gallon when driven on the path. Write a C++ program that calculates and displays the removal the car can tramp on individual tank of fog when driven in town and when driven on the path.

    Expert Reply

     

    Hi,

    Below is the C++ command control the question-

    // Example program
    #include <iostream>
    #include <string>

    int ocean()
    {
    float total_capacity=20;
    float avg_town=23.5;
    float avg_highway=28.9;
    float dist_town,dist_highway;
    dist_town=total_capacity*avg_town;
    dist_highway=total_capacity*avg_highway;
    std::cout<<“Total removal that can be trampled by a car in town is “<<dist_town;
    std::cout<<“nTotal removal that can be trampled by a car in path is “<<dist_highway;
    }

    Screenshot-