any help will be appreciated. thanks
here is the code:
Module MPG
Sub Main()
Dim milesPerGallon As Double = 0 'miles driven per tankful
Dim gallonsPerTank As Double = 0 'gallons used per tankful
Dim gallonsUsed As Double = 0 'running total of gallons used
Dim milesDriven As Double = 0 'running total of miles driven
Dim average As Double ' the average miles per gallon
Dim tank As Integer = 0 ' this counts how many tanks the user inputs
Console.WriteLine("Input the requested information for each tankful")
Console.WriteLine("Use -1 to terminate the application")
Console.WriteLine()
Console.WriteLine()
Do Until tank = -1
Console.WriteLine("Input gas used and mile driven on this tankful")
Console.Write("How many Gallons did you use in this tank? ")
gallonsUsed = Console.ReadLine()
If gallonsUsed = 0 Then
While gallonsUsed = 0
Console.Write("""0"" is not a valid number for amount of gallons used.")
Console.Write("How many Gallons did you use in this tank? ")
gallonsUsed = Console.ReadLine()
End While
End If
Console.Write("How many miles did you drive on this tank? ")
milesDriven = Console.ReadLine()
tank += 1
milesPerGallon = milesDriven + milesPerGallon
gallonsPerTank = gallonsUsed + gallonsPerTank
Console.WriteLine("This is tank # " & tank)
Loop
average = milesPerGallon / gallonsPerTank
Console.WriteLine("Your average is {0:F}" & average & " Miles Per Gallon(mpg)")
Console.WriteLine("Your totals: Number of tanks: " & tank)
Console.WriteLine("Your total miles driven: " & milesDriven)
Console.WriteLine("Your total gallons used: " & gallonsPerTank)
End Sub
End Module

New Topic/Question
Reply




MultiQuote









|