|
-
Feb 14th, 2012, 10:00 PM
#1
Thread Starter
New Member
[RESOLVED] [Excel] Output issues
For my Computational Techniques Class, we have to write a program that inputs temperature and wind speed, and computes the wind chill factor. The program also has to output what type of coat the person should wear.
Additionally, wind chill is not defined when t > 50 or when wind < 3 mph, so the program must define this. If a wind chill factor is not obtainable, the program must still output the temperature and give a coat rec.
I don't see where my issue is, I run the program, and it doesn't output much correctly. Some values are missing when i run the program and it ends before the calculation, and when it runs all the way through, no values are returned at all.
Help would be appreciated. Thanks in advance!
Code:
'in this program, a user will input wind speed and temperture to find the wind chill.'
'this is the declaration statement'
Option Explicit
Dim wc As Double
Dim t As Double
Dim mph As Double
Sub windchill()
'this part will input the data'
t = InputBox("What is the temperture?", , 50)
mph = InputBox("What is the wind speed?")
If t > 50 Then
MsgBox ("It must be colder than 50 degrees Farenheit for wind chill to be a factor.")
Cells(1, 1) = "Temperature in F"
Cells(2, 1) = t
Cells(1, 2) = "Type of coat?"
Cells(2, 2) = "No coat necessary!"
End If
If Cells(2, 1) > 50 Then End
If mph < 3 Then
MsgBox ("The wind must be blowing harder than 3 mph for windchill to be a factor.")
Cells(1, 1) = "Temperature in F"
Cells(2, 1) = t
Cells(1, 2) = "Wind speed in MPH"
Cells(2, 2) = mph
Cells(1, 3) = "Coat Recommendations"
End If
If 50 > t > 40 Then
Cells(2, 3) = "No coat necessary.!"
ElseIf 40 >= t >= 15 Then
Cells(2, 3) = "Wear a light coat, as it may get a bit nippy!"
ElseIf 15 > t Then
Cells(2, 3) = "Bring out the parka. Eskimos only may proceed."
End If
If Cells(2, 2) < 3 Then End
If t > 50 And mph > 3 Then
wc = (0.0817 * (3.71 * Sqr(mph) + 5.81 - 0.25 * mph) * (t - 91.4) + 91.4)
End If
If 50 > wc > 40 Then
MsgBox ("The weather is fine, no coat is needed!")
ElseIf 40 >= wc >= 15 Then
MsgBox ("A light coat is reccomended!")
ElseIf 15 > wc Then
MsgBox ("Bring out the parka. Eskimos only.")
End If
Cells(1, 1) = "Temperature in F"
Cells(1, 2) = "Wind speed in MPH"
Cells(1, 3) = "Wind chill in F"
Cells(2, 1) = t
Cells(2, 2) = mph
Cells(3, 2) = wc
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
|