ok prof in college asked us to write a program for a simple gradebook.
iv wrote it 3 times and still cant get it right.
he wants it to be able to put in 10 names/ids and 10 grades,and get a listing of those grades getting an average.
im butchering this thing and getting no where.
this is how far iv gotten on this version of it iv written.

Public Class student

   Private namevalue As String
   Private maximumgrade As Integer


   Public Sub New(ByVal namevalue As String, ByVal gradesArray As Integer)

      maximumgrade = 0
   End Sub

   Private _grade1 As Decimal
   Private _grade2 As Decimal
   Private _grade3 As Decimal
   Private _grade4 As Decimal
   Private _grade5 As Decimal
   Private _grade6 As Decimal
   Private _grade7 As Decimal
   Private _grade8 As Decimal
   Private _grade9 As Decimal
   Private _grade10 As Decimal

   Public ReadOnly Property grade() As Decimal
      Get
         Return _grade1

      End Get

   End Property
   Public ReadOnly Property grade2() As Decimal
      Get
         Return _grade2

      End Get
   End Property
   Public ReadOnly Property grade3() As Decimal
      Get
         Return _grade3

      End Get
   End Property
   Public ReadOnly Property grade4() As Decimal
      Get
         Return _grade4

      End Get
   End Property
   Public ReadOnly Property grade5() As Decimal
      Get
         Return _grade5

      End Get
   End Property
   Public ReadOnly Property grade6() As Decimal
      Get
         Return _grade6

      End Get
   End Property
   Public ReadOnly Property grade7() As Decimal
      Get
         Return _grade7

      End Get
   End Property
   Public ReadOnly Property grade8() As Decimal
      Get
         Return _grade8

      End Get
   End Property
   Public ReadOnly Property grade9() As Decimal
      Get
         Return _grade9

      End Get
   End Property
   Public ReadOnly Property grade10() As Decimal
      Get
         Return _grade10

      End Get

   End Property
   Public Function average() As Decimal
      While ((_grade1 + _grade2 + _grade3 + _grade4 + _grade5 + _grade6 + _grade7 + _grade8 + _grade9 + _grade10 / 10))


      End While
   End Function
End Class

any help in making it easyer would be aprcited, and tips on what im doing wrong an a lil explination of why its wrong (excuse the spelling been a very long day)

Not that I am going to go to the trouble of a class but...
'10 names..
Dim Student(1 to 10) As String
'with 10 grades each
Dim Grades(1 to 10, 1 to 10) As Integer
'For identifying student no in array
Dim StudentID As Integer
'for looping through grades and capturing total and result
Dim LoopCnt As Integer, Total As Integer, Result As Double

From the looks of it you have the basics of the user interface down so I will skip to the calculaton loop for a single student...

Total = 0
For LoopCnt = 1 To 10
  Total = Total + Grades(StudentID, LoopCnt)
Next LoopCnt
Result = Total \ 10

Good Luck

Not that I am going to go to the trouble of a class but...
'10 names..
Dim Student(1 to 10) As String
'with 10 grades each
Dim Grades(1 to 10, 1 to 10) As Integer
'For identifying student no in array
Dim StudentID As Integer
'for looping through grades and capturing total and result
Dim LoopCnt As Integer, Total As Integer, Result As Double

From the looks of it you have the basics of the user interface down so I will skip to the calculaton loop for a single student...

Total = 0
For LoopCnt = 1 To 10
  Total = Total + Grades(StudentID, LoopCnt)
Next LoopCnt
Result = Total \ 10

Good Luck

as in something like this

Public Class student5
   Dim Student(0 To 10) As String
   Dim Grades(0 To 10, 0 To 10) As Integer

   Dim StudentID As Integer
   Dim average(0 To 10 = total)

   Dim LoopCnt As Integer, Total As Integer, Result As Double



   Private _grade1 As Decimal

   Private _grade2 As Decimal

   Private _grade3 As Decimal

   Private _grade4 As Decimal

   Private _grade5 As Decimal

   Private _grade6 As Decimal

   Private _grade7 As Decimal

   Private _grade8 As Decimal

   Private _grade9 As Decimal

   Private _grade10 As Decimal
   Public ReadOnly Property grade() As Decimal

      Get

         Return _grade1

         Console.ReadLine()
         Console.WriteLine()

      End Get




   End Property

   Public ReadOnly Property grade2() As Decimal

      Get

         Return _grade2

         Console.ReadLine()
         Console.WriteLine()

      End Get

   End Property

   Public ReadOnly Property grade3() As Decimal

      Get

         Return _grade3
         Console.ReadLine()
         Console.WriteLine()


      End Get

   End Property

   Public ReadOnly Property grade4() As Decimal

      Get

         Return _grade4


         Console.ReadLine()
         Console.WriteLine()

      End Get

   End Property

   Public ReadOnly Property grade5() As Decimal

      Get

         Return _grade5


         Console.ReadLine()
         Console.WriteLine()
      End Get

   End Property

   Public ReadOnly Property grade6() As Decimal

      Get

         Return _grade6

         Console.ReadLine()
         Console.WriteLine()

      End Get

   End Property

   Public ReadOnly Property grade7() As Decimal

      Get

         Return _grade7

         Console.ReadLine()
         Console.WriteLine()

      End Get

   End Property

   Public ReadOnly Property grade8() As Decimal

      Get

         Return _grade8

         Console.ReadLine()
         Console.WriteLine()

      End Get

   End Property

   Public ReadOnly Property grade9() As Decimal

      Get

         Return _grade9
         Console.ReadLine()
         Console.WriteLine()


      End Get

   End Property

   Public ReadOnly Property grade10() As Decimal

      Get

         Return _grade10


         Console.ReadLine()
         Console.WriteLine()
      End Get



   End Property


   Private Property _total() As Decimal
      Get
         total = 0

         For Me.LoopCnt = 1 To 10

            Total = Total + Grades(StudentID, LoopCnt)

         Next LoopCnt
      End Get
      Set(ByVal value As Decimal)
         result = total \ 10
         Console.WriteLine("number of grades: total")
         Console.WriteLine("avg of grades: average")
      End Set
   End Property




End Class

something like that but I don't see where you pass in which studentid you want to total but I'm betting you have that someplace.

Also, it looks like (with the consol.writeline) that you may be programming in a different language than "Classic" Visual Basic 6.0 so in the future you may want to find the correct forum.

So, when building a program I do it step by step and your first step is to be able to add a student name and then be able to scroll through the added names.

Next step is to be able to select a student name and add a test score. This should probably have the ability to scroll through the test scores and to alter the test scores.

Then based upon those test scores, the ability to display an average for the selected student.


So how far have you actually progressed with this?

ok heres how far iv gotten on the script

Public Class student
   Private _studentName As String

   Private _grade1 As Integer
   Private _grade2 As Integer
   Private _grade3 As Integer
   Private _grade4 As Integer
   Private _grade5 As Integer
   Private _grade6 As Integer
   Private _grade7 As Integer
   Private _grade8 As Integer
   Private _grade9 As Integer
   Private _grade10 As Integer
   Public Sub New()
      _grade1 = 100
      _grade2 = 100
      _grade3 = 100
      _grade4 = 100
      _grade5 = 100
      _grade6 = 100
      _grade7 = 100
      _grade8 = 100
      _grade9 = 100
      _grade10 = 100
      _studentName = "pupil"

   End Sub
   Public Sub New(ByVal name As String)
      _grade1 = 100
      _grade2 = 100
      _grade3 = 100
      _grade4 = 100
      _grade5 = 100
      _grade6 = 100
      _grade7 = 100
      _grade8 = 100
      _grade9 = 100
      _grade10 = 100
      _studentName = name
   End Sub
   Public Property studentName() As String
      Get
         Return _grade1

      End Get
      Set(ByVal value As String)
         _studentName = value
      End Set
   End Property
   Public Property Grade1() As Integer

      Get
         Return _grade1

      End Get
      Set(ByVal value As Integer)
         If (value < 0) Then
            _grade1 = 0
         Else
            _grade1 = value
         End If
      End Set
   End Property
   Public Property Grade2() As Integer

      Get
         Return _grade2

      End Get
      Set(ByVal value As Integer)
         If (value < 0) Then
            _grade2 = 0
         Else
            _grade2 = value
         End If
      End Set
   End Property
   Public Property Grade3() As Integer

      Get
         Return _grade3

      End Get
      Set(ByVal value As Integer)
         If (value < 0) Then
            _grade3 = 0
         Else
            _grade3 = value
         End If
      End Set
   End Property
   Public Property Grade4() As Integer

      Get
         Return _grade4

      End Get
      Set(ByVal value As Integer)
         If (value < 0) Then
            _grade4 = 0
         Else
            _grade4 = value
         End If
      End Set
   End Property
   Public Property Grade5() As Integer

      Get
         Return _grade5

      End Get
      Set(ByVal value As Integer)
         If (value < 0) Then
            _grade5 = 0
         Else
            _grade5 = value
         End If
      End Set
   End Property
   Public Property Grade6() As Integer

      Get
         Return _grade6

      End Get
      Set(ByVal value As Integer)
         If (value < 0) Then
            _grade6 = 0
         Else
            _grade6 = value
         End If
      End Set
   End Property
   Public Property Grade7() As Integer

      Get
         Return _grade7

      End Get
      Set(ByVal value As Integer)
         If (value < 0) Then
            _grade7 = 0
         Else
            _grade7 = value
         End If
      End Set
   End Property
   Public Property Grade8() As Integer

      Get
         Return _grade8

      End Get
      Set(ByVal value As Integer)
         If (value < 0) Then
            _grade8 = 0
         Else
            _grade8 = value
         End If
      End Set
   End Property
   Public Property Grade9() As Integer

      Get
         Return _grade9

      End Get
      Set(ByVal value As Integer)
         If (value < 0) Then
            _grade9 = 0
         Else
            _grade9 = value
         End If
      End Set
   End Property
   Public Property Grade10() As Integer

      Get
         Return _grade10

      End Get
      Set(ByVal value As Integer)
         If (value < 0) Then
            _grade10 = 0
         Else
            _grade10 = value
         End If
      End Set
   End Property
   
   
   Public Function GetAverage() As Integer

      Return ((_grade1 + _grade2 + _grade3 + _grade4 + _grade5 + _grade6 + _grade7 + _grade8 + _grade9 + _grade10 / 10))


      
   End Function
   Public Function GetMin() As Integer
      Dim tempgrade As Integer
      tempgrade = _grade1

      If (_grade1 < tempgrade) Then
         tempgrade = _grade2
      End If
      If (_grade2 < tempgrade) Then
         tempgrade = _grade2
      End If
      If (_grade3 < tempgrade) Then
         tempgrade = _grade3
      End If
      If (_grade4 < tempgrade) Then
         tempgrade = _grade4
      End If
      If (_grade5 < tempgrade) Then
         tempgrade = _grade5
      End If
      If (_grade6 < tempgrade) Then
         tempgrade = _grade6
      End If
      If (_grade7 < tempgrade) Then
         tempgrade = _grade7
      End If
      If (_grade8 < tempgrade) Then
         tempgrade = _grade8
      End If
      If (_grade9 < tempgrade) Then
         tempgrade = _grade9
      End If
      If (_grade10 < tempgrade) Then
         tempgrade = _grade10
      End If
      Return tempgrade
   End Function
   Public Function Getmax() As Integer
      Dim tempgrade As Integer
      If (_grade1 > tempgrade) Then
         tempgrade = _grade2
      End If
      If (_grade2 > tempgrade) Then
         tempgrade = _grade2
      End If
      If (_grade3 > tempgrade) Then
         tempgrade = _grade3
      End If
      If (_grade4 > tempgrade) Then
         tempgrade = _grade4
      End If
      If (_grade5 > tempgrade) Then
         tempgrade = _grade5
      End If
      If (_grade6 > tempgrade) Then
         tempgrade = _grade6
      End If
      If (_grade7 > tempgrade) Then
         tempgrade = _grade7
      End If
      If (_grade8 > tempgrade) Then
         tempgrade = _grade8
      End If
      If (_grade9 > tempgrade) Then
         tempgrade = _grade9
      End If
      If (_grade10 > tempgrade) Then
         tempgrade = _grade10
      End If
      Return tempgrade
   End Function
   Public Sub displaystudet()
      Console.WriteLine("grade 1: " & _grade1.ToString())
      Console.WriteLine("grade 2: " & _grade1.ToString())
      Console.WriteLine("grade 3: " & _grade1.ToString())
      Console.WriteLine("grade 4: " & _grade1.ToString())
      Console.WriteLine("grade 5: " & _grade1.ToString())
      Console.WriteLine("grade 6: " & _grade1.ToString())
      Console.WriteLine("grade 7: " & _grade1.ToString())
      Console.WriteLine("grade 8: " & _grade1.ToString())
      Console.WriteLine("grade 9: " & _grade1.ToString())
      Console.WriteLine("grade 10: " & _grade1.ToString())
   End Sub
End Class

anything to crit on it

I see where you check each grade for < 0 but I do not see a check for > 100...

(0+0+0+0+0+0+0+0+0+1000)/10=100

Also, I see where you initialize each new student grades to 100. Doing this before they do any work is a free A and as far as I know, there are no free A's but that is more of a stylistic point but could come into question under the following scenario...

Teacher recieves work from student for lessons 1-4 and 7-10 but not for 5 and 6.

Your present way: ?+?+?+?+100+100+?+?+?+? thus forceing the teacher to go in and edit grades 5 and 6 because the student did not do any work.


Beyond that, does everything else work ok?

Good Luck

Is anyone writing a NOVEL here ..hehehe

Friend please post a simple vb file [ you both ] when i reading this i can't understand anything.It is easy to understand from an original file ....

I think a good if statement and for loop statement can make that big code to small one.
Is it a database project ??
Please just post a vb file with that code you posted here ...
I will try to help you ..

I think it is better to store that 10 students details in a small database for a short time.
And retrieve one by one to a text box.Use if to compare the grade and add those name and id to a list box who's grade is AVERAGE .....

Try it ...
Best of luck .....

well i would make it smaller to add a 4 loop to take over all the copy and pasted but thats how the proff was wanting it and we are going to add more things to it today in class that starts in 3 mins

Hey you want to get details of 10 students ... yes [ may be more ...].
As i mentioned you can use database for this.And it is only for a small work so it demands a small database.And this is the simple way [ i think ]

But wait .... it is just clear now i have a big doubt

Console.WriteLine("grade 7: " & _grade1.ToString())
Console.WriteLine("grade 8: " & _grade1.ToString())
Console.WriteLine("grade 9: " & _grade1.ToString())
Console.WriteLine("grade 10: " & _grade1.ToString())

Hey is this is possible with vb6 ??? I think this is vb.net code .....I used this code in my vb6 but it shows many errors ....!!!

Alright i will do this ..But i think you are working in a console application then wait i will try the code ...

try and browse my website
http://www.silentproject.tk
My Projects > 1st Year - 2nd Semister
download the Student Grades project..
i hope it will help you...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.