Loading

How I create a Grade Point Average in Visual Basic 2008

2 posts / 0 new
Last post
Offline
Joined: 06/09/2010
How I create a Grade Point Average in Visual Basic 2008

' Project name: Cook Project
' Project purpose: User enters numberofcredits and grade earned for a course.
'Enter numericgrade : That is enter 4,3,2,1 for grade earned
'Your code should calculate the gpa earned by the formula
' gpa = totalcredits/totalgradepoints
'Use a while loop to ask for numberofcredits and grade till the user enters empty string

Option Explicit Off
Option Strict Off
Option Infer Off

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

Anonymous
GPA

The Great online free tool is GPA Calculator

Pages

Add new comment

Filtered HTML

  • You may insert videos with [video:URL]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.