Measurement-conversion calculator-Volume, Weight, and Length The program is to p
ID: 3682871 • Letter: M
Question
Measurement-conversion calculator-Volume, Weight, and Length The program is to provide an interactive and dynamic GUI system that convert a measurement input to the correctly computed output between US Customary System and the Metric System, such as kilograms to ounces or yards to meters. The program will also convert measurements within the US Customary System or the Metric System, for example, meters to millimeters or gallons to cups. The number (like 3 or 15) and the input units (like foot or meter), and the output units (like yard or mile) of measurement must be designed and implemented to eliminate user errors. Be creative in designing the GUI to make it attractive and easy to use. The program must be written in Visual Basic.Explanation / Answer
' Description: Converts US length to metric length
Public Class frmLengthConversion
Private Sub btnConvert_Click(sender As Object, e As EventArgs) Handles btnConvert.Click
Dim miles As Integer = CInt(txtMiles.Text)
Dim yards As Integer = CInt(txtYards.Text)
Dim feet As Integer = CInt(txtFeet.Text)
Dim inches As Integer = CInt(txtInches.Text)
Dim totalInches As Double = 63360 * miles + 36 * yards + 12 * feet + inches
Dim totalMeters As Double = totalInches / 39.37
Dim kilometers As Integer = CInt(totalMeters / 1000)
Dim meters As Integer = CInt(totalMeters Mod 1000)
Dim centimeters As Double = (totalMeters * 100) Mod 100
lstOutput.Items.Add("The metric length is")
lstOutput.Items.Add(kilometers & " kilometers")
lstOutput.Items.Add((meters).ToString("N0") & " meters")
lstOutput.Items.Add((centimeters).ToString("N1") & " centimeters.")
End Sub
End Class