Share Your Source Code or Article

Do you have source code, articles, tutorials, web links, and books to share? You can write your own content here. You can even have your own blog.

Submit now...

Database Programming Made Easy

This tutorial will teach you step by step on how to connect and manipulate database. If you'd like to suggest a tutorial please write a comment at the bottom of this article.

Read more...

Hire Us to Do Your Work

Do you want a customized system? Do you want to setup your own website to do business? Then we are here to help you in your programming needs.

Read more...

Search

How I create a Grade Point Average in Visual Basic 2008
No replies
User offline. Last seen 12 weeks 6 days ago. Offline
Joined: 06/09/2010


' 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




Post new comment

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.

Step by Step Java Tutorial

In this tutorial you will learn how to program with Java. It has a rich of information to be educated well with Java.

Read more...

Do You Have Question?

Do you have any question related to computer programming? Visit our forum and post new topic on the category you like. Be gentle when asking a question.

Ask now...

Point of Sale

Point of Sale is very useful especially for supermarkets or restaurants. I have included a barcode scanner in this program. Please check it out.

Read more...