5
Answers

C# homework, using while and counter HELP

Ask a question
Drivers are concerned with the mileage obtained by their automobiles. One driver has kept track of several tankfuls of gasoline by recording miles driven and gallons 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.
Enter the miles used (-1 to quit): 287
Enter gallons: 13
MPG this tankful: 22.076923
Total MPG: 22.076923

Enter the miles used (-1 to quit): 200
Enter gallons: 10
MPG this tankful: 20.000000
Total MPG: 21.173913

Enter the miles used (-1 to quit): 120
Enter gallons: 5
MPG this tankful: 24.000000
Total MPG: 21.678571

Enter miles (-1 to quit): -1



Been trying to do this using while loop and counter on a console application, I missed the first couple of classes, and now i dont seem to figure out how to start!, please help me with this homework as im going to try to learn from it to write my next 2 assignments,thank you guys for your time.


Answers (5)