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)

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

Get

End Get

End Property
Get

End Get
End Property
Get

End Get
End Property
Get

End Get
End Property
Get

End Get
End Property
Get

End Get
End Property
Get

End Get
End Property
Get

End Get
End Property
Get

End Get
End Property
Get

End Get

End Property
Public Function average() As Decimal

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)

4
Contributors
10
Replies
11
Views
8 Years
Discussion Span
Last Post by jhai_salvador

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

Get

Console.WriteLine()

End Get

End Property

Get

Console.WriteLine()

End Get

End Property

Get

Console.WriteLine()

End Get

End Property

Get

Console.WriteLine()

End Get

End Property

Get

Console.WriteLine()
End Get

End Property

Get

Console.WriteLine()

End Get

End Property

Get

Console.WriteLine()

End Get

End Property

Get

Console.WriteLine()

End Get

End Property

Get

Console.WriteLine()

End Get

End Property

Get

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()
_studentName = "pupil"

End Sub
Public Sub New(ByVal name As String)
_studentName = name
End Sub
Public Property studentName() As String
Get

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

Get

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

Get

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

Get

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

Get

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

Get

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

Get

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

Get

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

Get

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

Get

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

Get

End Get
Set(ByVal value As Integer)
If (value < 0) Then
Else
End If
End Set
End Property

Public Function GetAverage() As Integer

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

End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End Function
Public Function Getmax() As Integer
Dim tempgrade As Integer
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End Function
Public Sub displaystudet()
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 .....

Edited by Vineeth K: n/a

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

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 ...

Edited by Vineeth K: n/a

try and browse my website
http://www.silentproject.tk
My Projects > 1st Year - 2nd Semister