Write a program to convert a US Customary system length in miles, yards, feet, a
ID: 3630081 • Letter: W
Question
Write a program to convert a US Customary system length in miles, yards, feet, and inches to a Matric length in kilometers, meters, and centimeters. After the numbers of miles,yards,feet, and inches are read from the text boxes, the length should be converted entirely to inches and then divided by 39.37 to obtain the value in meeters. The Int function used to total number of meters into a whole number of kilometers. The number of centimeters should be displayed to one decimal place. The needed formulas as follows:
total inches= 63360*miles+yards+12*feet+ inches
total meters= total inches/39.37
Kilometers= Int(meters/1000)
Explanation / Answer
Public Class Form1 03 04 Private Sub btnconvert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnconvert.Click 05 06 Dim miles As Double 07 Dim yards As Double 08 Dim feet As Double 09 Dim inches As Double 10 11 12 miles = txtmiles.Text 13 yards = txtyards.Text 14 feet = txtfeet.Text 15 inches = txtinches.Text 16 17 Dim totalInches As Double 18 Dim totalmeters As Double 19 Dim totalkilometers As Double 20 Dim totalCentimeters As Double 21 22 totalInches = 63360 * miles + 36 * yards + 12 * feet + inches 23 24 MOD total inches 25 26 totalmeters = totalInches / 39.37 27 28 totalkilometers = Int(totalmeters / 1000) 29 30 31 lstresult.Items.Add("the metric length is") 32 lstresult.Items.Add(totalkilometers & " kilometers") 33 lstresult.Items.Add(totalmeters & " meters") 34 lstresult.Items.Add(totalCentimeters & " centimeters.") 35 lstresult.Items.Add(totalInches) 36 37 End Sub 38 End Class
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.