Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Need help with homework problem in C# programming Drivers are concerned with the

ID: 3654615 • Letter: N

Question

Need help with homework problem in C# programming Drivers are concerned with the mileage obtained by their automobiles. One driver has kept track of several tankful of gasoline by recording miles driven and gallon used for each tankful. Develop a C++ program that uses a while statement to input the miles driven and gallons used for each tankful.The program should calculate and display the miles per gallon obtained for each tankful and print the combined miles per gallon obtained for all tankfuls up to this point. All averaging calculations should produce floating-point results. Display the results rounded to the nearest hundredth. Use the console class's ReadLine method and sentinel-controlled repetition to obtain data from the user.

Explanation / Answer

#pragma argsused #pragma hdrstop #include #include #include using namespace std; int main(int argc, char* argv[]) { // declare the variables double gallons; // read in the gallons double miles; // read in the miles double totalGallons; // calculate the total gallon input double totalMiles; // calculate the total mile input double total; // calculate the gallons/miles double average; // calculate the average overall double counter; // initialization phase total = 0; // initialise total counter = 1; // initialise loop counter cout