Simple Control: If, Else, and While
Statements
Due: Monday, Sept 24, 5:00 PM
Note: To submit this assignment,
create two project folders, called "Assignment2a" and
"Assignment2b", and submit them both.
-
Write a console application for Exercise 4.10 in the
text. A sample output of the program might look like this:
Number of
gallons in tank 1: 20
Number of miles on tank 1: 200
Average for tank 1: 10.0 miles per gallon.
Running average for all tanks: 10.0 miles per gallon.
Number of gallons in tank 2: 10
Number of miles on tank 2: 200
Average for tank 2: 20.0 miles per gallon.
Running average for all tanks: 13.3 miles per gallon.
Number of gallons of tank 3: 20
Number of miles on tank 3: 300
Average for tank 3: 15.0 miles per gallon.
Running average for all tanks: 14.0 miles per gallon.
Number of gallons of tank 4: -1
Thank you for using Mary's Merry Mileage Meter!
Note that the user input is underlined.
-
Write a console application for Exercise 4.14 in the text.
Hint: Read the entire five-digit number using ReadLine, and convert to
an integer in the normal way. Then use some simple math to determine
the five individual digits.