Reference no: EM13933332
have to do a vb application that accepts grade input double type) via an input box and loop until a string ("END") is entered.
The entries cannot be less than 0 or above 100.
I also must calculate highest and lowest score, average score and % above average.
I'm stuck at the loop as I'm not certain how to allow double type and string to be entered in inputbox and how to end the loop
with the string. So far my loop is duplicating entries in the listbox and not giving error message when <0 or >100 is entered
and not ending the loop as "END" is not being accepted.
I have an idea of how the code should be however I'm not sure where I'm going wrong with my code.
Please view my vb application code and guide me as to where I'm going wrong, please!
Thanking you in advance for any assistance rendered.
This is my code copied from VB 2010
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Label5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label5.Click
End Sub
Private Sub avscoreLabel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles avscoreLabel.Click
End Sub
Private Sub exitButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles exitButton.Click
Me.Close()
End Sub
Private Sub clearButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles clearButton.Click
highscoreLabel.Text = String.Empty
lowscoreLabel.Text = String.Empty
avscoreLabel.Text = String.Empty
ab_avgradeLabel.Text = String.Empty
inv_entLabel.Text = String.Empty
gradeListBox.Items.Clear()
End Sub
Private Sub calcButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles calcButton.Click
Dim scoreArray(24) As Double
Dim highest As Double
Dim lowest As Double
For X As Integer = 0 To scoreArray.GetUpperBound(0)
If scoreArray(X) > highest Then
highest = scoreArray(X)
End If
Next
For Y As Integer = 0 To scoreArray.GetUpperBound(0)
If scoreArray(Y) < lowest Then
lowest = scoreArray(Y)
End If
Next
lowscoreLabel.Text = lowest.ToString
highscoreLabel.Text = highest.ToString
End Sub
Private Sub gr_inputButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles gr_inputButton.Click
Dim scoreArray(24) As Double
Dim gradeInput As String
Dim gradeA As Integer
Dim gradeB As Integer
Dim gradeC As Integer
Dim gradeD As Integer
Dim gradeF As Integer
Dim gradeInvalid As Integer
Dim i As Integer
gradeListBox.Items.Clear()
gradeInput = InputBox("Please Enter Student Grade", "Enter Grade", , , ) 'priming
Do While gradeInput <> "END" Or i <= 24
scoreArray(i) = gradeInput
i = i + 1
gradeInput = InputBox("Please Enter Student Grade", "Enter Grade", , , ) 'updating
For i = 0 To i - 1
gradeListBox.Items.Add(scoreArray(i))
Next
Select Case gradeInput
Case 90 To 100
gradeA = gradeA + 1
Case 80 To 89
gradeB = gradeB + 1
Case 70 To 79
gradeC = gradeC + 1
Case 60 To 69
gradeD = gradeD + 1
Case Is < 69
gradeF = gradeF + 1
Case Is > 100
MessageBox.Show("Invalid Entry!" & Environment.NewLine & "Please Enter a Student Score between 0 & 100", "Roytec
Examinations", MessageBoxButtons.OK, MessageBoxIcon.Error)
gradeInvalid = gradeInvalid + 1
Case Is < 0
MessageBox.Show("Invalid Entry!" & Environment.NewLine & "Please Enter a Student Score between 0 & 100", "Roytec
Examinations", MessageBoxButtons.OK, MessageBoxIcon.Error)
gradeInvalid = gradeInvalid + 1
End Select
Loop
End Sub
End Class
YOU CAN VIEW THE APPLICATION REQUIREMENTS BELOW FOR YOUR REFERENCE:
You are required to create a Visual Basic application with an appropriate GUI for the Examinations Department. The program
must accept student exam results marked out of 100 via an input box until the value entered is "END". These values must
range between zero (0) and one hundred (100) and must be stored in an array. Invalid values entered must be flagged by a
message box which states "Values must be between 0 and 100". The maximum number of students in any class is 25. While
values are being stored in the array the program must keep track of the number of scores in the
(1) "A" range (90-100)
(2) "B" range (80-89)
(3) "C" range (70-79)
(4) "D" range (60-69)
(5) "F" range (below 60)
Also, the highest score, lowest score, the average (mean) score, the percentage of the grades that fall above the average and
the number of invalid entries must be calculated and displayed in the GUI.
Please Note:
a) You must use a Do loop count the number of grades.
b) You must use a case statement to count how many grades are in each range.
c) The number of grades should be stored as a variable and used in the calculation of the average