Hi im trying to do this project for class on functions. I am little confused on what i am doing wrong.
Here is the assignment
1) Write a program to calculate the wind chill. The wind chill is calculated by using the ambient temperature and the wind speed.
Wind chill temp = 91.4 + (temp - 91.4)(.474 + .304 sqrt(Wind Speed) - .0203(wind speed))
2) write a program to convert a numerical grade to a letter grade.
below 70 -F
70-79 - C
80-89 - B
90-100 - A
Here is the form code. I got the first part working, but not the 2nd assignment.
Dim grade As Integer
grade = TextBox1.Text
Label3.Text = Lettergrade(grade)
End Sub
Function Lettergrade(ByVal Numgrade As Integer) As Char
If Numgrade < 70 Then
Label3.Text = "F"
ElseIf Numgrade < 79 Then
Label3.Text = "C"
ElseIf Numgrade < 89 Then
Label3.Text = "B"
ElseIf Numgrade < 100 Then
Label3.Text = "A"
End If
End Function
Public Class Form1
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim IntTemp, IntWS As Integer
IntTemp = Val(TextBox1.Text)
IntWS = Val(TextBox2.Text)
Label1.Text = WindChill(IntTemp, IntWS)
End Sub
Function WindChill(ByVal Temp As Double, ByVal Wspeed As Double) As Double
Return 91.4 + (Temp - 91.4) * (0.474 + 0.304 * Math.Sqrt(Wspeed) - 0.0203 * (Wspeed))
End Function
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim grade As Integer
grade = TextBox1.Text
Label3.Text = Lettergrade(grade)
End Sub
Function Lettergrade(ByVal Numgrade As Integer) As Char
If Numgrade < 70 Then
Label3.Text = "F"
ElseIf Numgrade < 79 Then
Label3.Text = "C"
ElseIf Numgrade < 89 Then
Label3.Text = "B"
ElseIf Numgrade < 100 Then
Label3.Text = "A"
End If
End Function
End Class
Thanks