1 Replies - 187 Views - Last Post: 16 February 2019 - 07:58 PM Rate Topic: -----

#1 gunlake2012   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 15-February 19

GPA calculator

Posted 15 February 2019 - 10:33 PM

Looking for help. My assignment is to create a program that displays gpa. I must select male or female. Then Select the gpa and hit calculate everytime. SO i need to find the average. Each time i hit calculate it must add the current gpa and find the new current average. Thats where im having issues. cant figure out how to average it.

Thanks.



' Name:         GPA Project
' Purpose:      Calculate Average GPA for All Students/Gender Average
' Programmer:   Alex Fare on 02/15/2019

Option Explicit On
Option Strict On
Option Infer Off
Public Class Form1
    Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click
        Me.Close()
    End Sub

    Private dblGpa As Double
    Dim dblMale As Double
    Dim dblFemale As Double
    Private dblRun As Double
    Dim dblMaleCount As Double
    Dim dblFemaleCount As Double

    Private Sub btnCalc_Click(sender As Object, e As EventArgs) Handles btnCalc.Click
        Dim dblGpaSave As Double
        Dim dblAllStudents As Double
        Dim dblAverage As Double
        Dim dblAvgMale As Double
        Dim dblAvgFemale As Double


        Double.TryParse(lstGpa.Text, dblGpa)
        Double.TryParse(lblAllStudents.Text, dblAllStudents)
        Double.TryParse(lblFemaleStudents.Text, dblfemale)
        Double.TryParse(lblMaleStudents.Text, dblMale)

        Select Case True
            Case chkFemale.Checked
                dblAvgFemale += dblGpa + dblGpaSave
                dblFemaleCount += 1
                dblFemale = dblAvgFemale / dblFemaleCount
        End Select
        Select Case True
            Case chkMale.Checked
                dblAvgMale += dblGpa + dblGpaSave
                dblMaleCount += 1
                dblMale = dblAvgMale / dblMaleCount
        End Select


        dblAverage += dblGpa + dblGpaSave
        dblRun += 1
        dblAllStudents = dblAverage / dblRun



        lblAllStudents.Text = dblAllStudents.ToString("N2")
        lblMaleStudents.Text = dblMale.ToString("N2")
        lblFemaleStudents.Text = dblFemale.ToString("N2")












    End Sub
End Class




Is This A Good Question/Topic? 0
  • +

Replies To: GPA calculator

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14854
  • View blog
  • Posts: 59,272
  • Joined: 12-June 08

Re: GPA calculator

Posted 16 February 2019 - 07:58 PM

You are using SELECT statements wrong. Just use IF
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1