944,147 Members | Top Members by Rank

Ad:
Dec 5th, 2007
0

Need Help With Problem please

Expand Post »
sorry if this is really nooby but i cant seem to get pass the basics.
i need to write a program that accepts a series of exam marks, ended by -1. When the -1 is entered, it should display the following results in a text box,:
The average (mean) mark
The smallest and largest mark.
"Great work" if at least 30% of the students passed (got 40% or above). If not, it should display "High failure rate
Thank you for any help you cant offer
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ardsuggy is offline Offline
2 posts
since Dec 2007
Dec 5th, 2007
0

Re: Need Help With Problem please

use the following code. before use it take three textboxes(text1,trxt2,text3); one listbox(list1) ; one label(label1); and a commandbutton(command1)

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. Option Explicit
  2.  
  3. Private Sub Command1_Click()
  4. Dim num As Integer
  5.  
  6. num = 0
  7. begin:
  8. num = InputBox("Enter exam marks. -1 to end", "Marks")
  9. If num > -1 Then
  10. List1.AddItem num
  11. GoTo begin
  12. End If
  13.  
  14. Text1.Text = "Max :" & GetMaxMark
  15. Text2.Text = "Min :" & GetMinMark
  16. Text3.Text = "Avg :" & GetAvg
  17. Call Result
  18. End Sub
  19.  
  20. Public Function GetMaxMark() As Integer 'to find out the maximum mark
  21. Dim i As Integer, max As Integer
  22.  
  23. max = 0
  24. For i = 0 To List1.ListCount - 1 Step 1
  25. If Val(List1.List(i)) > max Then
  26. max = Val(List1.List(i))
  27. End If
  28. Next i
  29.  
  30. GetMaxMark = max
  31. End Function
  32.  
  33. Public Function GetMinMark() As Integer 'to find out the minimum mark
  34. Dim i As Integer, min As Integer
  35.  
  36. min = List1.List(0)
  37. For i = 0 To List1.ListCount - 1 Step 1
  38. If Val(List1.List(i)) < min Then
  39. min = Val(List1.List(i))
  40. End If
  41. Next i
  42.  
  43. GetMinMark = min
  44. End Function
  45.  
  46. Public Function GetAvg() As Double 'to find out the average
  47. Dim i As Integer, sum As Integer
  48.  
  49. sum = 0
  50. For i = 0 To List1.ListCount - 1 Step 1
  51. sum = sum + Val(List1.List(i))
  52. Next i
  53.  
  54. GetAvg = sum / List1.ListCount
  55. GetAvg = Format(GetAvg, "0.00")
  56. End Function
  57.  
  58. Public Sub Result() 'to print the overall result status
  59. Dim i As Integer, above40 As Integer, per As Double
  60.  
  61. above40 = 0
  62. For i = 0 To List1.ListCount - 1 Step 1
  63. If Val(List1.List(i)) >= 40 Then
  64. above40 = above40 + 1
  65. End If
  66. Next i
  67.  
  68. per = (above40 * 100) / List1.ListCount
  69. If per >= 30 Then
  70. Label1.Caption = "GREAT WORK" & vbCrLf & "Passing Rate :" & per & "%"
  71. Else
  72. Label1.Caption = "HIGH FAILURE RATE" & vbCrLf & "Passing Rate :" & per & "%"
  73. End If
  74. End Sub

see the screenshot also

hope this will help you
regards
Shouvik
Attached Thumbnails
Click image for larger version

Name:	untitled.JPG
Views:	7
Size:	18.7 KB
ID:	4532  
Reputation Points: 30
Solved Threads: 49
Posting Pro
choudhuryshouvi is offline Offline
553 posts
since May 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Visual Basic 4 / 5 / 6 Forum Timeline: Help needed with VB Assignment
Next Thread in Visual Basic 4 / 5 / 6 Forum Timeline: play .wav file with data





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC