Drivers are concerned with the mileage their automobiles get. One driver has kept track of several tankfuls of gasoline by recording the miles driven and gallons used for each tankful. Develop a C# app that will input the miles driven and gallons used (both as integers) for each tankful. The app should calculate and display the miles per gallon obtained for each tankful and display 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 hun- dredth. Use the Console class’s ReadLine method and sentinel-controlled iteration to obtain the data from the user.
a) Read the problem statement.
b) Formulate the algorithm using pseudocode and top-down, stepwise refinement.
c) Write a C# app.
d) Test, debug and execute the C# app.
e) Process three complete sets of data.
Top:
Determine the current and combined miles/gallon for each trip
First refinement:
Initialize variables
For each trip, input the miles driven and gallons used, then calculate and print the
miles/gallon for that trip
Calculate and print the overall average miles/gallon
Second refinement:
Initialize totalGallons to zero
Initialize totalMiles to zero
Prompt the user to enter the miles used for the first trip
Input the miles used for the first trip (possibly the sentinel)
While the sentinel value (-1) has not been entered for the miles Prompt the user to enter the gallons used for the current trip Input the gallons used for the current trip
Add miles to the running total in totalMiles
Add gallons to the running total in totalGallons
If gallons is not zero
Calculate and print the miles/gallon
If totalGallons is not zero
Calculate and print the totalMiles/totalGallons
Prompt the user for the next trip’s number of miles
Input the miles used for the next trip
You might also like to view...
Which of the following is NOT an available option for Headers & Footers?
A) Don't show on title slide B) Show filepath C) Slide number D) Date and time
________ drives are the hard disk drives that act as receptacles for evidence acquired from the suspect's hard drive
Fill in the blank(s) with the appropriate word(s).
Answer the following statement(s) true (T) or false (F)
Employees surfing the Internet can cost companies millions of dollars.
The ______________________ of evidence supports the integrity of your evidence.
Fill in the blank(s) with the appropriate word(s).