Question

In: Computer Science

Code, pls. Thank you. Exercise - MPG Calculator Create a Windows Forms application and call it...

Code, pls. Thank you.

Exercise - MPG Calculator Create a Windows Forms application and call it MPGCalculator Build a form that looks like the form in the video provided. The form consists of 4 labels, 2 textboxes and 3 buttons Name all controls properly. Certain labels do not have to be named Pay attention to video and set all design time properties accordingly. The "x" should be a hot key for the exit button When Calculate is clicked, you should calculate the MPG and display it. Round to 2 decimal places. (google it!) When Clear is clicked, clear the form. When Exit is clicked, close the form

Solutions

Expert Solution

Below is the solution:

Public Class frmMilesPerGallon
    Private Sub frmMilesPerGallon_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        txtGallon.Text = ""
        txtMiles.Text = ""
        Label3.Text = "MPG is: "
        label4.Text = "0"
    End Sub

    'Exit Events
    Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
        Me.Close()
    End Sub

    'calculate button event
    Private Sub btnCalculate_Click(sender As Object, e As EventArgs) Handles btnCalculate.Click
        Dim miles As Integer
        Dim gallon As Integer
        Dim mpg As Double

        If (Integer.TryParse(txtMiles.Text, miles) And Integer.TryParse(txtGallon.Text, gallon)) Then 'Accept the miles and gallon integer value
            mpg = miles / gallon 'miles dived by gallon will get the result
            label4.Text = mpg.ToString("0.00")
        Else
            MessageBox.Show("Enter valid value!")
        End If
    End Sub

    'clear button event will clear the all form object value
    Private Sub btnClear_Click(sender As Object, e As EventArgs) Handles btnClear.Click
        txtGallon.Clear()
        txtMiles.Clear()
        Label3.Text = "MPG is: "
        label4.Text = "0"
    End Sub
End Class


Related Solutions

Must be in Visual C# using windows forms : Create an application that opens a specified...
Must be in Visual C# using windows forms : Create an application that opens a specified text file and then displays a list of all the unique words found in the file. Hint: Use a LINQ method to remove all duplicate words.
***IN C# ONLY, USING WINDOWS FORMS*** --NO JAVA--. Create a GUI application in C# that calculates...
***IN C# ONLY, USING WINDOWS FORMS*** --NO JAVA--. Create a GUI application in C# 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...
Using C# Windows App Form Create a simple calculator using +,-,*,/ Please show code GUI Code...
Using C# Windows App Form Create a simple calculator using +,-,*,/ Please show code GUI Code for calculator menus radio button input text boxes
Create code In visual Basic, Windows forms that uses case statements to convert the day of...
Create code In visual Basic, Windows forms that uses case statements to convert the day of the week (entered by the user into an integer. (Sunday = 1, Monday = 2, etc.) For this code, think about error checking. What will your code do if the user enters “dog” for example (which is not a day of the week)? What will your code do if the user enters a number or other incorrect input?
Windows Forms application using Visual Basic: Create a class called Character that a role-playing game might...
Windows Forms application using Visual Basic: Create a class called Character that a role-playing game might use to represent a character within the game. A character should include six stats as instance variables – strength, dexterity, constitution, intelligence, wisdom and charisma (all types are int). Your class should have a constructor that initializes these six instance variables. Provide Properties with an appropriate set and get block for each instance variable. In addition, provide a method named getStatsTotal that calculates the...
unctional Requirements  Design a Windows Forms Application for a movie database providing appropriate controls for...
unctional Requirements  Design a Windows Forms Application for a movie database providing appropriate controls for the following data:  Movie Name  ISBN13 Number (optional)  Release Date  Location (Canadian OR International)  Genre (Action, Biography, Comedy, Drama, Educational, History, Horror, Musical, Mystery, Romance, Sci-Fi, Thriller OR Western)  Rating (1 to 5 stars)  Duration (in minutes)  Price  Support loading and saving of the data for multiple movies to a Sequential Text file  Display...
----- Please solve the questions with the code below. Thank you. ----- Exercise Overview Refactor your...
----- Please solve the questions with the code below. Thank you. ----- Exercise Overview Refactor your code to enhance the user experience and to use objects and classes. All functional requirements in Project 1 remain, except where enhancing the system replaces specific functions. Functional Requirements The console entry point for the user inputs is on the same line as the prompt. (new) User enters name at the beginning of a session. System covers four math operations – addition, subtraction, multiplication,...
Create a Java windows application to manage a list of stocks 1. Add a class Stock...
Create a Java windows application to manage a list of stocks 1. Add a class Stock with the following fields: companyName, pricePerShare, numberOfShares (currently owned) and commission (this is the percent you pay a financial company when you purchase or sell stocks. Add constructor, getters and methods: ***purchaseShares (method that takes the number of shares purchased, updates the stock and return the cost of purchasing these shares make sure to include commission. ***sellShares (method that takes the number of shares...
In C# Create a windows application which accepts the month number and displays the month name...
In C# Create a windows application which accepts the month number and displays the month name in a label.   Use a nested if... else statement to determine the month name. For months not in the range 1-12 display the message "Not a valid month"
Create an application containing an array that stores 5 integers. The application should call five methods...
Create an application containing an array that stores 5 integers. The application should call five methods from Array2 class that in turn (1) display all the integers, (2) display all the integers in reverse order, (3) display the sum of the integers, (4) display all values less than a limiting argument, and (5) display all values that are higher than the calculated average value. Save the file as ArrayTest.java.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT