I need help with this on how to makea gpa calculator using visual basic Create a
ID: 3782750 • Letter: I
Question
I need help with this on how to makea gpa calculator using visual basic Create a GPA calculator. Ask the user to input a list of classes and the number of tests per class. Once the user has entered this initial information, allow the list to be saved when the user exits the program. When the program starts, any existing data should be loaded automatically. After the user has entered the list of classes and number of tests for each class, the user can then enter grades for each test. Create a button that allows the user to request a GPA calculation at any time. (GPA = average for each class averaged for the total number of classes in a semester.) All programs should have basic menu options that allow the user to exit the program and perform tasks you deem necessary for the program to function correctly. After creating the program, be sure to debug and test your code.
Explanation / Answer
Public Class MainForm
Private Sub exitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles exitButton.Click
Me.Close()
End Sub
Private Sub enterButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles enterButton.Click
' calculates and displays the total credit hours and GPA
Dim creditHourscounter As Integer
Dim gradePointscounter As Integer
Dim credithours As Integer
Dim grades As Integer
Dim StringCreditHours As String = String.Empty
' Dim NumericGrade As String
Dim creditsAccumulator As Integer
Dim gradeAccumulator As Integer
Const prompt As String = "Enter number of credit hours"
Const title As String = "Credit hours"
' Dim numberOfCredits As Integer
Dim numberOfGrades As Double
Dim totalCredits As Double
Dim totalGradePoints As Double
Dim gpa As Double
Dim gradenumericValue As String = String.Empty
'StringCreditHours = InputBox("Enter number of credit hours: 4 or 3")
'Write the Do while/until loop to ask for user inputHours till String is empty
'Do Loop
' StringCreditHours = InputBox("Enter number of credit hours")
StringCreditHours = InputBox(Prompt, title)
Do While StringCreditHours <> String.Empty
Integer.TryParse(StringCreditHours, credithours)
StringCreditHours = InputBox(prompt, title)
creditHourscounter = creditHourscounter + 1
creditsAccumulator = creditsAccumulator + credithours
Loop
totalCredits = creditsAccumulator
numberOfGrades = creditsAccumulator
gradenumericValue = InputBox("Enter NumericGrade: 4 or 3 or 2 or 1 or 0")
Do While gradenumericValue <> String.Empty
Decimal.TryParse(gradenumericValue, grades)
gradenumericValue = InputBox("Enter NumericGrade: 4 or 3 or 2 or 1 or 0")
gradePointscounter = gradePointscounter + 1
gradeAccumulator = gradeAccumulator + grades
Loop
'Do While gradenumericValue <> 0
'gradenumericValue = InputBox("Enter NumericGrade: 4 or 3 or 2 or 1 or 0")
'gradePointscounter = gradePointscounter + 1
'Loop
' NumericGrade = InputBox("Enter NumericGrade: 4 or 3 or 2 or 1 or 0")
'Convert string to Numeric data
'Calculate totalgradepoints and totalcredit hours
'each gradepoints is got by product of numberOfCredits * gradenumericValue
totalGradePoints = grades * credithours
'creditHourscounter = creditHourscounter + 1
' totalGradePoints = gradePointscounter
' totalCredits = gradePointscounter * StringCreditHours
' Loop
' Do While <> 5
'Convert string to Numeric data
''StringCreditHours = InputBox("Enter number of credit hours")
'Calculate totalgradepoints and totalcredit hours
'each gradepoints is got by product of numberOfCredits * gradenumericValue
' Integer.TryParse(StringCreditHours, hours)
' Loop
'totalGradePoints = numberOfGrades
gpa = totalGradePoints/gradeAccumulator
gpaLabel.Text = "GPA: " & gpa
numberOfGradesLabel.Text = "Number of grades entered: " _
& numberOfGrades
End Sub
End Class