Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

Visual Basic Homework Help


  • Please log in to reply

#1
indeera

indeera

    New Member

  • Member
  • Pip
  • 1 posts
I have a bit of an issue with a visual basic project for class.
The assignment is to create a program that gives you your average grade,
(is it just me or do they do one of those in every CSIT class) Then it is
supposed to give you the number of above average grades. I got the first part
easily enough but can't seem to figure out the 2nd part. How do I get it to find
"highgrades", nothing I've tried so far is working;

My code is here,

Public Class Form1

Private Sub btnRecord_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnRecord.Click
ListBox1.Items.Add(TextBox1.Text)
TextBox1.Clear()
TextBox1.Focus()
End Sub

Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
Dim sum As Double = 0
Dim highgrades As Double = 0
If ListBox1.Items.Count > 0 Then
For i As Integer = 0 To ListBox1.Items.Count - 1
sum += CDbl(ListBox1.Items(i))





Next

TextBox2.Text = FormatNumber(sum / ListBox1.Items.Count, 2)
TextBox3.Text = CStr(highgrades)
Else


End If
End Sub
End Class
  • 0

Advertisements


#2
Artellos

Artellos

    Tech Secretary

  • Global Moderator
  • 3,915 posts
Without telling you exactly what code to use (that would defeat the purpose of the homework assignment), try describing how you 'plan' to accomplish your assignment.

I know that getting an average of say 10 grades it not that hard. You add them together and divide by 10, right?
Now, say you got the following numbers;

5 / 6 / 8 / 7 / 8 / 4 / 8 / 7 / 9 / 10
The average of this would be 7.2

Now what if you would do this yourself? (Not with the program) How would you do it?
You would compare each number in the list of 10 numbers to the number 7.2, right?
So could you write some code that would compare each number in the list to 7.2?

Regards,
Olrik
  • 0

#3
markjeggar

markjeggar

    New Member

  • Member
  • Pip
  • 1 posts
Average grade means average of those grades.
Eg: said above reply

Now, say you got the following numbers;

5 / 6 / 8 / 7 / 8 / 4 / 8 / 7 / 9 / 10
The average of this would be 7.2


High grade means highest of given grades.

eg:max(gade) result is 10.

you can put all numbers into an arraylist and sort the arraylist , then u will get max value

arraylist vb.net sample..

http://csharp.net-in...p-arraylist.htm

jegga.
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP