Need Help With Problem please

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Dec 2007
Posts: 2
Reputation: ardsuggy is an unknown quantity at this point 
Solved Threads: 0
ardsuggy ardsuggy is offline Offline
Newbie Poster

Need Help With Problem please

 
0
  #1
Dec 5th, 2007
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
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 538
Reputation: choudhuryshouvi is an unknown quantity at this point 
Solved Threads: 49
choudhuryshouvi's Avatar
choudhuryshouvi choudhuryshouvi is offline Offline
Posting Pro

Re: Need Help With Problem please

 
0
  #2
Dec 5th, 2007
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
untitled.JPG  
Shouvik_The_Expert_Coder
Have a problem? Don't worry just give me a call and I'll fix it for you.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Visual Basic 4 / 5 / 6 Forum


Views: 939 | Replies: 1
Thread Tools Search this Thread



Tag cloud for Visual Basic 4 / 5 / 6
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC