Write a Program to determine a students GPA. The student should enter the grade
ID: 3656729 • Letter: W
Question
Write a Program to determine a students GPA. The student should enter the grade (A,BC,D, or F) and the number of of credit hours for a course, and then click on the record this course button. The user should then repeat this process for all his or her courses. After all courses have been recorded, the user should click on the calculate GPA button. A function procedure should be used to calculate the quality points for a course. This below is the program that I attempted to write, it does not work. Public Class frmGPA Dim hours As Double Dim grade As String Private Sub btnRecordCourse_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRecordCourse.Click Dim hours As Double hours += mtbCredithours.Text grade = mtbGrade.Text End Sub Private Sub btnCalculateGPA_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculateGPA.Click Dim GPA As Double Dim qualityPoints As Double GPA = qualityPoints / hours txtGpa.Text = calculatePoints(GPA) End Sub Function calculatePoints(ByVal qualityPoints As Double) As Double Select Case qualityPoints Case "A" Return qualityPoints = hours * 4 Case "B" Return qualityPoints = hours * 3 Case "C" Return qualityPoints = hours * 2 Case "D" Return qualityPoints = hours * 1 Case Else qualityPoints = 0 End Select End Function End Class (Chegg might change the format that I posted, sorry)Explanation / Answer
Public Class GPA_Form Private Sub exitButton_Click(sender As System.Object, e As System.EventArgs) Handles exitButton.Click Me.Close() End Sub Private Sub entdatButton_Click(sender As System.Object, e As System.EventArgs) Handles entdatButton.Click Const Prompt As String = "Enter number of Credit Hours:" Const Title As String = "Credit Hours" Const Prompt2 As String = "Enter grades:" Const Title2 As String = "Grades" Dim inputCredit As String Dim inputGrades As String Dim creditHrs As Integer Dim grades As Char Dim gradesCounter As Integer Dim creditHrsAccumulator As Integer Dim point As Integer Dim gpaTot As Integer Dim pntAccumulator As Integer inputCredit = InputBox(Prompt, Title) inputGrades = InputBox(Prompt2, Title2) Do While inputCredit String.Empty Integer.TryParse(inputCredit, creditHrs) Char.TryParse(inputGrades, grades) gradesCounter += 1 creditHrsAccumulator += creditHrs Select Case grades Case Is >= "A" point = 4 Case Is >= "B" point = 3 Case Is >= "C" point = 2 Case Is >= "D" point = 1 Case Is >= "F" point = 0 End Select pntAccumulator += point gpaTot = pntAccumulator / gradesCounter tchData.Text = creditHrsAccumulator.ToString("N0") numGrEnt.Text = gradesCounter.ToString("N0") gpaData.Text = gpaTot.ToString("N2") inputCredit = InputBox(Prompt, Title) inputGrades = InputBox(Prompt2, Title2) Loop End Sub End ClassRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.