4 Replies - 515 Views - Last Post: 17 October 2013 - 02:41 PM Rate Topic: -----

#1 bpalafox21993  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 15-October 13

Hw assignment Help if you can.

Posted 15 October 2013 - 01:32 PM

Ok i have the code that asks the user to input 3 numeric values of their grade which ranges from 1-100. then divides those 3 values in order to output the average and grade. Now i need to display all other grades such as A- A+ or an A because the code only displays A B C D F. In addition i have to display the grade point range and grade point value for example an A+ would have a grade point range of 97-100 and a value of 4.000. Do i just modify the ElseIf dblAverage statements in order to finish the final steps. Thoughts ? Here is the code

[/
public Class Form1

    Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
        ' Variables to hold scores and the average score
			Dim dblScore1 As Double
			Dim dblScore2 As Double
			Dim dblScore3 As Double
			Dim dblAverage As Double
			Const NUM_SCORES As Integer = 3

			' Constant for a high score.
			Const dblHIGH_SCORE As Double = 95.0
			Try
				' Copy the TextBox scores into the variables.
				dblScore1 = CDbl(txtScore1.Text)
				dblScore2 = CDbl(txtScore2.Text)
				dblScore3 = CDbl(txtScore3.Text)

					' Calculate the average score.
				dblAverage = (dblScore1 + dblScore2 +
				 dblScore3) / NUM_SCORES

				' Display the average, rounded to 2 decimal places.
            lblAverage.Text = dblAverage.ToString("n2")

            ' Display the letter grade.
            If dblAverage < 60 Then
                lblGrade.Text = "F"
            ElseIf dblAverage < 70 Then
                lblGrade.Text = "D"
            ElseIf dblAverage < 80 Then
                lblGrade.Text = "C"
            ElseIf dblAverage < 90 Then
                lblGrade.Text = "B"
            ElseIf dblAverage <= 100 Then
                lblGrade.Text = "A"
            End If

            ' If the score is high, give the student priase.
            ' Otherwise, give some encouragement. 
            If dblAverage > dblHIGH_SCORE Then
                lblMessage1.Text = "Congradulations! Great Job!"
            Else
                lblMessage1.Text = "Keep trying!"
            End If
        Catch
            ' Display an error message.
            lblMessage1.Text = "Scores must be numeric."
        End Try
    End Sub

    Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
        ' Clear the TextBoxes and Labels.
        txtScore1.Clear()
        txtScore2.Clear()
        txtScore3.Clear()
        lblAverage.Text = String.Empty
        lblMessage.Text = String.Empty
        lblGrade.Text = String.Empty

        ' Reset the focus.
        txtScore1.Focus()
    End Sub

    Private Sub btnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExit.Click
        ' Close the form.
        Me.Close()
    End Sub
End Class
]

This post has been edited by modi123_1: 15 October 2013 - 01:39 PM
Reason for edit:: please use code tags


Is This A Good Question/Topic? 0
  • +

Replies To: Hw assignment Help if you can.

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9096
  • View blog
  • Posts: 34,176
  • Joined: 12-June 08

Re: Hw assignment Help if you can.

Posted 15 October 2013 - 03:07 PM

This looks to VB.NET and not java.. moving.
Was This Post Helpful? 0
  • +
  • -

#3 _ELement_8215  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 34
  • Joined: 14-December 11

Re: Hw assignment Help if you can.

Posted 17 October 2013 - 02:25 PM

I'd say you could do something like this: (but of course applied to all possible grades)

ElseIf dblAverage <= 100 Then
  If dblAverage >=97 AndAlso dblAverage <= 100 Then
    'A+
    lblGrade.Text = "A+"
    'set the value here of an A+
  'ElseIf whatever an A- is
    'set the value of an A-
  Else
    'A
    lblGrade.Text = "A"
    'set the value here of an A
  End If
End If



This may or may not be the most optimized way to get the assignment done, but it'll give you a jumping off point at least.

This post has been edited by _ELement_8215: 17 October 2013 - 02:26 PM

Was This Post Helpful? 0
  • +
  • -

#4 andrewsw  Icon User is online

  • Fire giant boob nipple gun!
  • member icon

Reputation: 3371
  • View blog
  • Posts: 11,420
  • Joined: 12-December 12

Re: Hw assignment Help if you can.

Posted 17 October 2013 - 02:32 PM

Just to note that:

If dblAverage >=97 AndAlso dblAverage <= 100 Then

you wouldn't need the second part of this condition because the previous line already establishes that the average is <= 100.
Was This Post Helpful? 0
  • +
  • -

#5 bpalafox21993  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 15-October 13

Re: Hw assignment Help if you can.

Posted 17 October 2013 - 02:41 PM

Thanks guys I figured it out also just need another label and label.txt to display the gpa.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1