Question
The assingment is as follows Grade Point Average Write a program to calculate a student's GPA. The user should enter the grade (A,B,C,D, or F)
The assingment is as follows
Grade Point Average Write a program to calculate a student's GPA. The user should enter the grade (A,B,C,D, or F) and the number 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 the 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.
Below is my code for a program on visual basic 2013. The only problem I am having I put in BOLD. It is Public Function CalculatePoints(grade As String, creditHours As Integer)
I have to do this project with option strict on. So I get the following error. Calculate points is underlined in blue and it says "option strict requires all function, property, and operation declarations to have an "AS" clause.
I just want this to go alway without changing the what my program does. I feel like this should be a simple change but couldn't figure it out. please help
Please paste all code with problem fixed. Again this program has to run with option Strict on.
Thank you.
Names of controls
combobox-- cboGrade
textbox for credit hours-- txtCredit
textbox for Gpa-- txtGPA
record button-- btnRecord
calulate gpa button-- btnCalc
Public Class Form1 'Declares floating points and floating hours Public floatingPoints As Double, floatingHours As Integer
Private Sub btnRecord_Click(sender As Object, e As EventArgs) Handles btnRecord.Click
Dim qualityPoints As Double Dim creditHours As Integer Dim grade As String
'This is if no grade is selected a message box appears If cboGrade.SelectedIndex 4 Then MsgBox("Please enter vaild credit hours") Else grade = CStr(cboGrade.SelectedItem) creditHours = CInt(txtCredit.Text) qualityPoints = CDbl(CalculatePoints(grade, creditHours)) floatingPoints += qualityPoints floatingHours += creditHours ClearForm() End If
End Sub Public Sub ClearForm() cboGrade.SelectedIndex = -1 cboGrade.Text = "Select Grade" txtCredit.Text = "" End Sub 'Function procudure that calculates quality points for a course Public Function CalculatePoints(grade As String, creditHours As Integer) Dim qualityPoints As Double Select Case (grade) Case "A" qualityPoints = 4 * creditHours Case "B" qualityPoints = 3 * creditHours Case "C" qualityPoints = 2 * creditHours Case "D" qualityPoints = 1 * creditHours Case Else qualityPoints = 0
End Select Return qualityPoints End Function
Private Sub btnCalc_Click(sender As Object, e As EventArgs) Handles btnCalc.Click Dim gpa As Double If floatingHours > 0 Then gpa = floatingPoints / floatingHours txtGPA.Text = FormatNumber(gpa, 2) Else MsgBox("No courses were entered") Exit Sub End If
End Sub
End Class
Form Grade (A B.) Select Grade Credit Hours tri Ip Record This Course Calculate GPA er GPA
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started