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 of gas the tank holds and the number of miles the car can be driven on a full tank. When the Calculate MPG button is clicked, the application should display the number of miles that the car can be driven per gallon of gas. The form should also have a clear button that clears the input and results, and an EXIT button that ends the application. If the user fails to enter numeric values, display appropriate error message and do not attempt to perform calculations. THe applications form should appear as show below
Ans:-
"program to generate the miles per gallon calculator.
Public Class formMilesPerGallon
"To compute the mpg value by getting the values from the text boxes
Private Sub btnCalculateMPG_click(sender As Object,e As EventArgs) Handles CalculateMPG.click
"declaration of required variables
Dim numGallons As Double = 0
Dim numMiles As Double = 0
Dim MPG As Double = 0
"To convert the textbox values to doubles
numGallons=Double.Parse(txtNumGallons.Text)
numMiles=Double.Parse(txtNumMiles.Text)
MPG=numMiles/numGallons "Formula to calculate mpg
lblMPG.Text=MPG.ToString("n2") "set mpg value to txtmpg by setting the decimal place to 2
End Sub
"To clear the content of input text boxes.
Private Sub btnClear_Click(sender As Object,e As EventArgs) Handles btnClear.Click
txtNumGallons.Clear()
txtNumMiles.Clear()
lblMPG.Text=""
End Sub
"To exit from the application if we press the exit buton
Private Sub btnExit_Click(sender As Object,e As EventArgs) Handles btnExit.Click
Me.close()
End Sub
End Class
sample output:-
enter the data in the fields of text boxes as shown below
Now press the calculate MPG button and the result will be shown as 37.50 at the immediate text box.
And if we press the clear button all data in the text boxes will get erased.
Finally to exit press Exit button.
create an application in VISUAL BASIC that calculates a cars gas mileage. The formula for calculating...
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,...
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...
7. Miles-per-Gallon 6pts A car’s miles-per-gallon (MPG) can be calculated with the following formula: MPG = Miles driven / Gallons of gas used Design a program that asks the user for the number of miles driven and the gallons of gas used. It should calculate the car’s miles-per-gallon and display the result on the screen.Draw a flowchart in algorithmic language
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...
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 will input the miles driven and gallons used for each tankful. The program should calculate and display the miles per gallon obtained for each tankful. After processing all input information, the program should calculate and print the combined miles per gallon obtained for all tankfuls....
Classwork 2-2: Input & Formatting A car's miles-per-gallon (MPG) can be calculated using the formula: MPG - miles driven/gallons of gas used Write a program that asks the user for the car's make, number of miles driven and the gallons of gas used. It should calculate the car's MPG and displays the result rounded to 2 decimal places. Example "Your Honda's MPG is 28.56" On Blackboard, submit a screenshot of successfully running and testing your code on HackerRank.com: www.hackerrank.com/csc124-chapter-2-classwork (2nd...
In this exercise, you’ll upgrade a version of the MPG application so the error messages are displayed in span elements to the right of the text boxes. Open the HTML and JavaScript files in this folder: exercises_short\ch06\mpg\ Then, run the application and click the Calculate MPG button to see that an error message is displayed in an alert dialog box for each of the two input fields. 2. In the HTML file, add a span element after the input element...
***JAVASCRIPT*** I need JAVASCRIPT codes for this question. Also a little explanation and full screenshots of the codes. Short 6-1 Upgrade the MPG application In this exercise, you'll upgrade a version of the MPG application so the error messages are displayed in span elements to the right of the text boxes. Estimated time: 10 to 15 minutes. Calculate Miles Per Gallon Miles Driven Mies must be numeric and greater than zero Gallons of Gas Used Gallons must be numeric and...
NAME: RECORD ANSWER WITH CORRECT UNITS AND CORRECT SIG FIGS IN BOX PROVIDED-USE SCIENTIFIC NOTATION IF OVENIENT. SHOW UNIT CONVERSION PROCESS IN SPACE PROVIDED BELOW EACH QUESTION FOR FULL CREDIT. 1. Assume your hybrid car gets 38.0 miles per gallon (mpg) and the current price per gallon of regular, unleaded gasoline is $2.52. The car's gas tank holds 11.5 gallons. a. How far (in km) can the car travel on a tank of gas? b. What will be the cost...
Travel Expenses Create a GUI in C# Visual Studios application that calculates and displays the total travel expenses of a business person on a trip. Here is the information that the user must provide: • Number of days on the trip • Amount of airfare, if any • Amount of car rental fees, if any • Number of miles driven, if a private vehicle was used • Amount of parking fees, if any • Amount of taxi charges, if any...