|
-
Feb 21st, 2006, 11:24 AM
#1
Thread Starter
Junior Member
Homework Help Needed
Hey guys this is my first post Long time forum reader 
This is my homework question:
Write a to convert a U.S. Customary System length in miles, yards, feet, and inches to a Metric System length in kilometers, meters, and centimeters. After the number 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.97 to obtain the value in meters. The Int function should be used to break the total number of meters into a whole number of kilometers and meters. The number of centimeters should be displayed to one decimal place. Some of the needed forumlas are as follows.
total inches = 63360 * miles + 36 *yards +12 * feet + inches
total meters = total inches/39.37
Kilometers - Int(meters/1000)
In the diagram for the sample run:
Miles: 5
Yards: 20
Feet: 2
Inches: 4
When you click on the button " Covert To Metric" the follow is the output:
The metric length is
8 kilometers
65 meters
73.5 centimeters
Using the numbers in the sample run:
Total Inches = 317548
Total Meters - 317548/39.37 = 8065.735331
Kilometers = 8.065735331
So, I was able to get the Kilometers right baesd on the formula given. Howeverfor meters I seem to be off by quite a large number. I realize that I have calculated the "total meters" but is there something else I have to do to convert "total meters" into the Metric system?
Cheers,
Last edited by sadio; May 3rd, 2010 at 10:52 AM.
-
Feb 21st, 2006, 02:16 PM
#2
Re: Homework Help Needed
Welcome to the Forums.
 Originally Posted by sadio
The metric length is
8 kilometers
65 meters
73.5 centimeters
Compare these numbers to:
 Originally Posted by sadio
Total Meters - 317548/39.37 = 8065.735331
Do you notice any similarities? Specifically, re-express your total metres in km, m and cm. No, you're not mistaken. It really is as easy as that. Unless, of course, you don't understand what the difference between km, m and cm is.
zaza
-
Feb 21st, 2006, 08:16 PM
#3
Thread Starter
Junior Member
Re: Homework Help Needed
Thank you very much. I did try that out and got it to work =-)!
In case you are wondering what i did
Dim totalinches, totalmeters, kilometers, totalmeters2, totalcm As Double
txtmiles.Text = CDbl(txtmiles.Text)
txtyards.Text = CDbl(txtyards.Text)
txtfeet.Text = CDbl(txtfeet.Text)
txtinches.Text = CDbl(txtinches.Text)
totalinches = 63360 * txtmiles.Text + 36 * txtyards.Text + 12 * txtfeet.Text + txtinches. Text
totalmeters = totalinches / 39.37
kilometers = Int(totalmeters / 1000)
totalmeters2 = Int(totalmeters - kilometers * 1000)
totalcm = (totalmeters - kilometers * 1000 - totalmeters2) * 100
With lstresults.Items
.Add("The Metric Length is")
.Add(kilometers & " Kilometers")
.Add(totalmeters2 & " Meters")
.Add(FormatNumber(totalcm, 1) & " Centimeters")
End With
Well I got another question and since its related to this question I'll just edit this post.
Now the second part of the question is saying:
Have the user enter the Kilometers, Meters, and Centimeters... and the output would show: Miles, Yards, Feet, and Inches. Its the reverse of the above question. Its just that I'm excately sure where to start solving this problem. Do the 3 above formulas given in the first example help with this problem or are they totally unrelated?
Last edited by sadio; Feb 21st, 2006 at 09:32 PM.
-
Feb 22nd, 2006, 12:43 PM
#4
Re: Homework Help Needed
You have the conversion from total inches to total metres. Given one, you can immediately tell the other.
And you have the numbers to convert miles, feet and inches into total inches, so you just run this in reverse.
zaza
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|