Visual Basic: In this assignment, you are asked to create a small program that w
ID: 3603779 • Letter: V
Question
Visual Basic:
In this assignment, you are asked to create a small program that will calculate a semester grade point average using arrays. This is to give you familiarity with the concept. It is not meant to be tedious, but is meant to give you an exposure.
Your task is as follows:
Design a form that has five buttons: homework, tests, quizzes, projects, and calculate. At the outset, you should only see the homework button. As you progress, make the next button visible.
When you press a button for the grading areas, you are prompted to enter grades for each area. Do this with an input box inside of a for loop. Store each value to the next spot in the array. If you do not enter a number, make it input -1. In other words, you are making the grade not there. The class has 10 homework assignments, 3 tests, 6 quizzes, and 1 project.
When you get to the calculate button, your goal will be to count the number of submitted grades in each category and calculate the grade for the semester, outputting that information in a message box. If the number -1 shows up, do not count it. For purposes of averaging, count it as a 0.
Homework is 30% of the grade, quizzes are 30% of the grade, tests are 30% of the grade, and the project is 10% of the grade.
Use a select case block to assign the letter grade. Use the grading scheme from the syllabus to do that.
Again, this task is not meant to be complicated. It is very repetitive. The point is that you can see the value of having an array structure rather than having to work through names. In the video, I said it is not really possible to iterate over names. It is possible, but more complicated. That is something we will look at in CIS 312 if you choose to take that course, but for right now, we are not going to worry about that. Arrays are the way to go here.
Explanation / Answer
Public Class frmGrades Declare total As Double Declare grade As String Declare name as String Declare grade1 as double Declare grade2 as double Declare grade3 as double Private Sub btnGrade_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGrade.Click Input(Name) Input(Grade1, Grade2, Grade3) Display(name),":", determineGrade() End Sub Function determineGrade() As String If (grade1) < (grade2) Then If (grade1) < (grade3) Then total = ((grade3) + (grade2)) / 2 Else total = ((grade1) + (grade2)) / 2 End If Else If (grade2) < (grade3) Then total = ((grade1) + (grade3)) / 2 Else total = ((grade1) + (grade2)) / 2 End If End If If total >= 90 And total = 80 Then grade = "B" ElseIf total >= 70 Then grade = "C" ElseIf total >= 60 Then grade = "D" Else grade = "F" End If Return grade End Function End ClassRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.