2 Replies - 220 Views - Last Post: 11 April 2013 - 07:39 PM Rate Topic: -----

#1 mandeepcheema11  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 11-April 13

Visual Basic: Need help with small eroor

Posted 11 April 2013 - 06:59 PM

So my purpose is to display average, number of students and how many students failed.
I am able to output average and number of students but can't output how many students have failed.
can anyone let me know what my error is, i have spent few an hour into this.



Sub Main()
Dim p, total As Double
Dim Answer As String = "yes"
Dim numberofstudents As Integer
Dim average As Double
Dim mark As Double
total = 0
numberofstudents = 0
p = 0
mark = 0


Console.WriteLine(" enter a mark, yes or no??")
Answer = Console.ReadLine()
Do While Answer = "yes"
numberofstudents = numberofstudents + 1
Console.WriteLine(" what is your mark?")
p = Console.ReadLine
total = total + p
Console.WriteLine(" would you like to know more?")
Answer = Console.ReadLine()
If mark >= 50 Then
Console.WriteLine("Fail")
Console.ReadLine()

End If
Loop

average = total / numberofstudents

Console.WriteLine(" average is " & average & " for " & numberofstudents & " students ")
Console.WriteLine("Number of students failed = " & mark & "")
Console.ReadLine()
End Sub

Is This A Good Question/Topic? 0
  • +

Replies To: Visual Basic: Need help with small eroor

#2 mandeepcheema11  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 11-April 13

Re: Visual Basic: Need help with small eroor

Posted 11 April 2013 - 07:28 PM

I tried removing a line but now it gives me 50 when it outputs how many people failed. i am having trouble with this



Sub Main()
Dim p, total As Double
Dim Answer As String = "yes"
Dim numberofstudents As Integer
Dim average As Double
Dim mark As Double
total = 0
numberofstudents = 0
p = 0
mark = 50


Console.WriteLine(" enter a mark, yes or no??")
Answer = Console.ReadLine()
Do While Answer = "yes"
numberofstudents = numberofstudents + 1
Console.WriteLine(" what is your mark?")
p = Console.ReadLine
total = total + p
Console.WriteLine(" would you like to know more?")
Answer = Console.ReadLine()

Loop

average = total / numberofstudents

Console.WriteLine(" average is " & average & " for " & numberofstudents & " students ")
Console.WriteLine("Number of students failed = " & mark & "")
Console.ReadLine()
End Sub

View Postmandeepcheema11, on 11 April 2013 - 07:27 PM, said:

I tried removing a line but now it gives me 50 when it outputs how many people failed. i am having trouble with this



Sub Main()
Dim p, total As Double
Dim Answer As String = "yes"
Dim numberofstudents As Integer
Dim average As Double
Dim mark As Double
total = 0
numberofstudents = 0
p = 0
mark = 50


Console.WriteLine(" enter a mark, yes or no??")
Answer = Console.ReadLine()
Do While Answer = "yes"
numberofstudents = numberofstudents + 1
Console.WriteLine(" what is your mark?")
p = Console.ReadLine
total = total + p
Console.WriteLine(" would you like to know more?")
Answer = Console.ReadLine()

Loop

average = total / numberofstudents

Console.WriteLine(" average is " & average & " for " & numberofstudents & " students ")
Console.WriteLine("Number of students failed = " & mark & "")
Console.ReadLine()
End Sub

It gives me everyhting else correct, just not displaying how many students failed. it says 0 all the time
Was This Post Helpful? 0
  • +
  • -

#3 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10372
  • View blog
  • Posts: 38,411
  • Joined: 27-December 08

Re: Visual Basic: Need help with small eroor

Posted 11 April 2013 - 07:39 PM

Do not open duplicate threads.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1