去年我做了一些java编程,但今年我已经启动了Visual Basic,并且由于某些原因无法绕过Windows Forms Apps。
这是一项家庭作业,这是一个问题:
编写一个接受五个输入值的程序并将它们存储到一个数组中。程序应使用循环以相反的顺序显示这五个数字。然后程序应该使用函数计算五个数字的平均值,然后显示数组中所有大于五个数字平均值的数字。
这是我到目前为止编写的代码,非常感谢任何帮助完成此程序
Option Strict On
Public Class Form1
Private Sub outputButton_Click(sender As Object, e As EventArgs) Handles outputButton.Click
'Variables
Dim fiveNumbers(4) As Integer
If IsNumeric(FirstNumTextBox.Text) And IsNumeric(SecondNumTextBox.Text) _
And IsNumeric(ThirdNumTextBox.Text) And IsNumeric(FourthNumTextBox.Text) _
And IsNumeric(FifthNumTextBox.Text) Then
fiveNumbers(0) = CInt(FirstNumTextBox.Text)
fiveNumbers(1) = CInt(SecondNumTextBox.Text)
fiveNumbers(2) = CInt(ThirdNumTextBox.Text)
fiveNumbers(3) = CInt(FourthNumTextBox.Text)
fiveNumbers(4) = CInt(FifthNumTextBox.Text)
End If
'For i As Integer = 4 To 0 Step -1
'fiveNumbers(i) = CInt(CInt(ReverseTextBox.Text).ToString)
'Next
End Sub
Function average(fiveNumbers() As Integer) As Double
average = (fiveNumbers(0) + fiveNumbers(1) + fiveNumbers(2) _
+ fiveNumbers(3) + fiveNumbers(4)) / 5
Return average
For i As Integer = 0 To 4 Step 1
If fiveNumbers(i) > average Then
End If
Next
End Function
结束班