这次的亚洲梦想杯是中国队赢了还是韩国队?

实验30

(2) 编写计算关于 x和y变量的函数式子 的程序(其中x=5,y=9)。–(x ^ 3 + x * y + y ^ 3) / (2 * x * y)?(3) 编写计算y=ln20+|x-16|的程序。–Math.Log(20) + Math.Abs(x - 16)?(4) 编写计算y=0.231x+1.36值的程序。–0.231 * x + 1.36

(5)一个物体做斜抛运动,设初速度为v0,斜抛方向与地面夹角为θ,落地时所用的时间 ,落地时物体运动的射程 (其中重力加速度g=9.81米/秒2,θ的单位为:弧度)。编写程序,计算它落地所需时间和落地时运动的射程。要求:①用InputBox函数输入初速度为v0和角度θ(单位为:度);②在程序中,重力加速度g定义为符号常量。– t = 2 * x * Math.Sin(y * Math.PI / 180) / g–s = x * Math.Sin(2 * y * Math.PI / 180) / g

(4) 用IF…THEN…ELSEIF…ENDIF语句编写根据成绩,给出等级的程序。等级划分如下:?90分以上  A ?80-89分 B?70-79分 C?60-69分 D60分以下 F

daan:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

'用实验30-1-(1)

Dim a As String, b As String, c As String

Dim x1 As Single, x2 As Single

a = InputBox("输入A", "输入据Y", , 500, 500)

b = InputBox("输入B", "输入数据Y", , 500, 500)

c = InputBox("输入C", "输入数据Y", , 500, 500)

x1 = -b + Math.Sqrt(b ^ 2 - 4 * a * c) / 2 / a

x2 = -b - Math.Sqrt(b ^ 2 - 4 * a * c) / 2 / a

MsgBox("x1=" & Format(x1, "###.###") & " x2=" & Format(x2, "###.###"))

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

'实验30-1-(2)

Dim x, y As Integer, z As Single

x = 5 : y = 9

z = (x ^ 3 + x * y + y ^ 3) / (2 * x * y)

MsgBox("(x ^ 3 + x * y + y ^ 3) / (2 * x * y)=" & z)

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

'实验30-1-(3)

Dim x, y As Single

x = InputBox("输入数值x")

y = Math.Log(20) + Math.Abs(x - 16)

MsgBox("ln20+|x-16|=" & y)

End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

'实验30-1-(4)

Dim x, y As Single

x = InputBox("输入数值x")

y = 0.231 * x + 1.36

MsgBox("0.231 * x + 1.36=" & y)

End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

'实验30-1-(5)

Dim x, y, t, s As Single

Const g = 9.81

x = InputBox("输入初速度x")

y = InputBox("输入斜抛方向与地面的夹角y")

t = 2 * x * Math.Sin(y * Math.PI / 180) / g

s = x * Math.Sin(2 * y * Math.PI / 180) / g

MsgBox("落地使用的时间t=" & t & "秒 落地时物体运动的射程s=" & s & "米")

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

'用IF-Then语句编写奇偶数

Dim x As Integer

'Randomize '初始化随机数生成器

x = Int(Microsoft.VisualBasic.Rnd() * 100)

If Int(x / 2) = x / 2 Then '判断数是否奇偶。用2除该数,该数取整等于其不取整的结果即为偶数。

MsgBox(x & "是偶数")

Else

MsgBox(x & "是奇数")

End If

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

'在3个数中找出最大值和最小值

Dim x As Single, y As Single, z As Single, max_num As Single, min_num As Single

x = InputBox("请输入第一个数")

y = InputBox("请输入第二个数")

z = InputBox("请输入第三个数")

max_num = x : min_num = x

If y > max_num Then max_num = y

If z > max_num Then max_num = z

If y < min_num Then min_num = y

If z < min_num Then min_num = z

MsgBox("最大数是 " & max_num & " 最小数是 " & min_num)

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

'用IF-Then-Else-Endif 编写变量t分段求值的计算程序

Dim t As Integer, f As Single

t = Val(InputBox("请输入 t值(∞,120)或者[120,∞):", "输入自变量tz值"))

If t < 120 Then

f = 0.06 * t + 2

Else

f = 0.06 * t * 0.85

End If

MsgBox(" f= " & f)

End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

'用IF-Then-Else-Endif 编写成绩等级评定程序

Dim grade As Integer

grade = InputBox("请输入您的考试成绩", , , 500, 500)

If grade > 90 Then

MsgBox("您的考试成绩为A级")

ElseIf grade >= 80 Then

MsgBox("您的考试成绩为B级")

ElseIf grade >= 70 Then

MsgBox("您的考试成绩为C级")

ElseIf grade >= 60 Then

MsgBox("您的考试成绩为D级")

Else

MsgBox("您的考试成绩为F级")

End If

End Sub