Question

In Visual Basics - Program 2. Mileage Write a program which allows the user to enter...

In Visual Basics - Program 2. Mileage

Write a program which allows the user to enter the distance they have traveled by car in miles and the

number of gallons of gasoline they used to travel the distance. Be sure to allow for decimal places for

both values. Your results should show miles per gallon and kilometers per gallon. A kilometer is 0.61

miles, and this value must be stored as a constant. Your outputs must be formatted to 2 decimal

0 0
Add a comment Improve this question Transcribed image text
Answer #1


Module VBModule
Sub Main()
Console.WriteLine("Enter the distance in miles:")
Dim distance
distance=Console.ReadLine()
distance = CDbl(Val(distance))
Console.WriteLine("No of gallons of gasoline:")
Dim gallons
gallons=Console.ReadLine()
gallons = CDbl(Val(gallons))
Dim miles_per_gallon
Dim km_per_gallon
miles_per_gallon=distance/gallons
km_per_gallon=(distance/gallons)*(0.61)
Console.WriteLine("miles per gallon:")
Console.WriteLine(String.Format("{0:0.00}", miles_per_gallon) )
Console.WriteLine("Kms per gallon:")
Console.WriteLine(String.Format("{0:0.00}", km_per_gallon) )
End Sub
End Module

Add a comment
Know the answer?
Add Answer to:
In Visual Basics - Program 2. Mileage Write a program which allows the user to enter...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a Python program that does the following: Obtains the following input from a user: Mileage...

    Write a Python program that does the following: Obtains the following input from a user: Mileage at beginning of measurement period Mileage at end of measurement period Gallons of fuel consumed Calculates and displays: Miles driven Miles per gallon Kilometers driven Liters of fuel consumed Kilometers per liter Incorporate some Selection structure logic into it: If a vehicle gets less than 15 miles per gallon, display the message:       "Your vehicle has criminally low fuel efficiency." If it gets 15...

  • create an application in VISUAL BASIC that calculates a cars gas mileage. The formula for calculating...

    create an application in VISUAL BASIC that calculates a cars gas mileage. The formula for calculating the miles that a car can travel per gallon of gas is MPG = Miles/Gallon In the formula MPG is miles-per-gallon, miles is the number of miles that can be driven on a full tank of gas, and gallons is the number of gallons that the tank holds. The applications form should have TextBox controls that let the user enter the number of gallons...

  • A liter is 0.264179 gallons. Write a program that will read in the number of liters...

    A liter is 0.264179 gallons. Write a program that will read in the number of liters of gasoline consumed by the user's car and the number of miles per gallon the car delivered. Your program should allow the user to repeat this calculation as often as the user wishes. Define a function to compute the number of miles per gallon. Your program should use a globally defined constant for the number of liters per gallon. After doing this... Modify your...

  • Write a Python program that does the following: Obtains the following input from a user: Mileage...

    Write a Python program that does the following: Obtains the following input from a user: Mileage at beginning of measurement period Mileage at end of measurement period Gallons of fuel consumed Calculates and displays: Miles driven Miles per gallon Kilometers driven Liters of fuel consumed Kilometers per liter Also incorporate some selection structure logic into it. If a vehicle gets less than 15 miles per gallon, display the message:       "Your vehicle has criminally low fuel efficiency." If it gets...

  • Write program PSEUDOCODE that prompts the user for their name and then will compute a car's...

    Write program PSEUDOCODE that prompts the user for their name and then will compute a car's miles per gallon given input of miles driven and gallons of gas used. It should also convert those given numbers into metric and show kilometers driven, liters used, and kilometers per liter. All with well formatted output. Submit: C++ Programming Warm-Up Exercise PSEUDOCODE for the algorithm that compute's a car's miles per gallon given input of miles and convert these numbers into metric and...

  • 1. a. The car I drive is a Toyota Prius C; its average mileage rating is...

    1. a. The car I drive is a Toyota Prius C; its average mileage rating is 52.0 mpg. Convert this rating into units of kilometers traveled per liter of gasoline consumed. (3 pts) b. Gasoline is a mixture of several hydrocarbon compounds, but let's assume that it consists of only one: octane. If the density of octane is 0.703 g/mL, use the result from part a to calculate how many kilometers the Prius C can travel on one kilogram of...

  • I need trying to figure out how I can make create a code in Python with this exercise for I am having trouble doing so. Miles Per Gallon Calculator Write a GUI program that calculates a car's gas...

    I need trying to figure out how I can make create a code in Python with this exercise for I am having trouble doing so. Miles Per Gallon Calculator Write a GUI program that calculates a car's gas mileage. The program's window should have Entry widgets that let the user enter the number of gallons of gas the car holds, and the number of miles it can be driven on a full tank. When a Calculate MPG button is clicked,...

  • // Enter your name as a comment for program identification // Program assignment TripCost.cpp // Enter...

    // Enter your name as a comment for program identification // Program assignment TripCost.cpp // Enter your class section, and time /* The program TripCost.cpp uses pointers to calculate    the cost of a trip depending on the cost of a gallon    of gas, the number of miles, and the number of miles    per gallon a car gets. */ /* The cost of gas, the number of miles, and number of    miles per gallon is entered. */...

  • Hi, Hi, I need someone to write a program in Phython 3.6, and please I will...

    Hi, Hi, I need someone to write a program in Phython 3.6, and please I will appreciate if the code is error free and indented correctly. The output would be preferable. thanks Write a GUI program that translates the Latin words to English. The window should have three buttons, one for each Latin word. When the user clicks a button, the program displays the English translation in a label. 3. Miles Per Gallon Calculator Write a GUI program that calculates...

  • ouiz Me: Quiz Me: 2.B-4 Solve application problems involving units Submit Quiz You plan to take...

    ouiz Me: Quiz Me: 2.B-4 Solve application problems involving units Submit Quiz You plan to take a 1236-mile trip in your car, which averages 24 miles per gallon. How many gallons of gasoline should you expect to use? Would a car that has only half the gas mileage require twice as much gasoline for the same trip? Explain. You should expect to use about □ gallons of gasoline (Type an integer or a decimal.) Would a car that has only...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT