I have an assignment for school and I am new to programming. For the assignment I need to make a survey with at least 4 choices that uses 2 arrays. It must be done in a console application. How do I make it loop and count/store the responses until the user enters "N" at strAnswer=Conso le.readline? Where/what loop would I use?
[code=vbnet]
Module Module1
Sub Main()
Dim strAnswer As String
Console.WriteLi ne("Do you want to answer survey")
strAnswer = Console.ReadLin e()
While Not strAnswer.ToUpp er.StartsWith(" N")
Dim resp(3) As Integer
Console.WriteLi ne("Pick a number between 1 and 4")
resp(0) = Console.ReadLin e
'declare response frequency array
Dim frequency As Integer() = New Integer(4) {}
' count frequencies
For answer As Integer = 0 To resp.GetUpperBo und(0)
frequency(resp( answer)) += 1
Next
Console.WriteLi ne("Choices" & vbTab & "Frequency" )
'display output
For rating As Integer = 1 To frequency.GetUp perBound(0)
Console.WriteLi ne(rating & vbTab & frequency(ratin g))
Next
Console.WriteLi ne("Do you want to answer survey")
strAnswer = Console.ReadLin e()
End While
End Sub
End Module[/code]
[code=vbnet]
Module Module1
Sub Main()
Dim strAnswer As String
Console.WriteLi ne("Do you want to answer survey")
strAnswer = Console.ReadLin e()
While Not strAnswer.ToUpp er.StartsWith(" N")
Dim resp(3) As Integer
Console.WriteLi ne("Pick a number between 1 and 4")
resp(0) = Console.ReadLin e
'declare response frequency array
Dim frequency As Integer() = New Integer(4) {}
' count frequencies
For answer As Integer = 0 To resp.GetUpperBo und(0)
frequency(resp( answer)) += 1
Next
Console.WriteLi ne("Choices" & vbTab & "Frequency" )
'display output
For rating As Integer = 1 To frequency.GetUp perBound(0)
Console.WriteLi ne(rating & vbTab & frequency(ratin g))
Next
Console.WriteLi ne("Do you want to answer survey")
strAnswer = Console.ReadLin e()
End While
End Sub
End Module[/code]
Comment