Create a Visual Basics program to calculate grades, There will be four categorie
ID: 3744751 • Letter: C
Question
Create a Visual Basics program to calculate grades,
There will be four categories of grades:
- Test scores
- Lab scores
- Quizzes
- Final Exam
First, the user will determine the % each of the above categories count toward the overall grade. You will need to tell the user how you would like this data entered. Note that all percentages should add up to 100%.
The user will then determine the maximum value earned for each category. Some users may have everything on a 100 point scale, but some may not.
The user will enter the following grades:
- (3) Test Scores
- (5) Lab Scores
- (4) Quiz Scores
- (1) Final Exam Grade
You may assume that the user will not exceed the maximum value for the category (we will deal with this in a later chapter).
Once all of the data is entered, you will calculate the final average (on a 100 point scale) and assign a final letter grade on a 10 point grading scale (90-100 is an A, 80-89.99 is a B, etc.).
Explanation / Answer
ScreenShot
---------------------------------------------------------------------------------
Program
Public Class frmGradeCalculation
Private Sub btnCalculateGrade_Click(sender As Object, e As EventArgs) Handles btnCalculateGrade.Click
'Declaration variables for total scores of each category
Dim test_score As Double
Dim lab_score As Double
Dim quizz_score As Double
Dim final_score As Double
Dim final_grade As Double
'Calculate total scores of each category and convert it into 100 scale
test_score = (CDbl(txtTestScore1.Text) + CDbl(txtTestScore2.Text) + CDbl(txtTestScore3.Text)) / 3
lab_score = (CDbl(txtLab1.Text) + CDbl(txtLab2.Text) + CDbl(txtLab3.Text) + CDbl(txtLab4.Text) + CDbl(txtLab5.Text)) / 5
quizz_score = (CDbl(txtQuizz1.Text) + CDbl(txtQuizz2.Text) + CDbl(txtQuizz3.Text) + CDbl(txtQuizz4.Text)) / 4
final_score = CDbl(txtFinalScore.Text)
'Calculate final grade score according to each sections weightage
'Here test score has 30%,lab Score has 10%,quizz has 10% and finals has 50%
final_grade = test_score * 0.3 + lab_score * 0.1 + quizz_score * 0.1 + final_score * 0.5
'According to that score calculate grade and display result.
If final_grade >= 90 And final_grade <= 100 Then
MsgBox("Final Grade= A")
ElseIf final_grade >= 80 And final_grade <= 89.99 Then
MsgBox("Final Grade= B")
ElseIf final_grade >= 70 And final_grade <= 79.99 Then
MsgBox("Final Grade= C")
ElseIf final_grade >= 60 And final_grade <= 69.99 Then
MsgBox("Final Grade= D")
ElseIf final_grade < 60 Then
MsgBox("Final Grade= F")
End If
End Sub
End Class
-------------------------------------------
Output