Public Class frmMiniChecks
Private Sub btnCheckEven_Click(sender As Object, e As EventArgs) Handles
btnCheckEven.Click
Dim num1 As Integer
Dim num2 As Integer
Dim resultEven As String = "The Even Numbers are: "
Dim resultOdd As String = "The Odd Numbers are: "
num1 = CInt(InputBox("Enter a Valid Number: "))
num2 = CInt(InputBox("Enter a Valid Number: "))
For x = num1 To num2 Step 1
If x Mod 2 = 0 Then
resultEven &= x.ToString + ", "
Else
resultOdd &= x.ToString + ", "
End If
Next
MessageBox.Show(resultEven, "Even Numbers", MessageBoxButtons.OK,
MessageBoxIcon.Information)
MessageBox.Show(resultOdd, "Odd Numbers", MessageBoxButtons.OK,
MessageBoxIcon.Information)
End Sub
Private Sub btnCheckFactors_Click(sender As Object, e As EventArgs) Handles
btnCheckFactors.Click
Dim num As Integer
Dim resultFac As String = "The Factors are: "
Dim numOfFactors As Integer = 0
num = CInt(InputBox("Enter a Number:"))
For x = 1 To num Step 1
If num Mod x = 0 Then
resultFac &= x.ToString + ", "
numOfFactors += 1
End If
Next
MessageBox.Show(resultFac, "Factors of a Number")
If numOfFactors = 2 Then
MessageBox.Show(num & " is a Prime Number", "Prime Number Promt")
Else
MessageBox.Show(num & " is Not a Prime Number", "Non - Prime Number Promt")
End If
End Sub
Private Sub btnFindAveAge_Click(sender As Object, e As EventArgs) Handles
btnFindAveAge.Click
Dim numOfStudents As Byte = CInt(Val(InputBox("Enter the NUmber of Students in the
Class", "Student Age App")))
If numOfStudents <= 0 Then
MessageBox.Show("No Student is the Class", "Student App ")
Else
Dim studAges(numOfStudents - 1) As Integer
Dim totalAge As Integer = 0
Dim avAge As Single = 0.0
For x = 0 To studAges.GetUpperBound(0) Step 1
studAges(x) = CInt(Val(InputBox("Enter student " & x + 1 & " age: ", "Student
Age App")))
totalAge += studAges(x)
Next
avAge = Math.Round(totalAge / numOfStudents, 2)
MessageBox.Show("The average age of the Students is :" & avAge)
MessageBox.Show("The Age of student is " & studAges(InputBox("Enter the Student
ID")))
End If
End Sub
End Class