Dim NumberVoted as Decimal
Dim NumberOfCandidates as String
Console.WriteLine("How many candidates would you like? The number must be between 2 and 4 inclusive")
NumberOfCandidates = Console.ReadLine
Do Until NumberOfCandidates >= 2 and NumberOfCandidates <= 4 and NumberOfCandidates mod 1 = 0
Console.WriteLine("Invalid number of candidates, please enter a whole number between 2 and 4 inclusive")
NumberOfCandidates = Console.ReadLine
numberofcandidates = numberofcandidates - 1
Console.WriteLine("Enter names of each candidate in order")
For Count = 0 to NumberOfCandidates
cNames(Count) = Console.ReadLine
Console.WriteLine("---------------------------------------")
For Count = 0 to NumberOfCandidates
Console.WriteLine("Candidate " & Count + 1 & " is " & cNames(Count))
Console.WriteLine("---------------------------------------")
Console.WriteLine("Enter the number of voters")
nVoters = Console.ReadLine
Do Until nVoters >= 1 and nVoters <= 30 and nVoters Mod 1 = 0
Console.WriteLine("Invalid number of voters, please enter a whole number between 1 and 30 inclusive")
nVoters = Console.ReadLine
Dim Votes(NumberOfCandidates) as Integer
Console.WriteLine("Enter candidate number you would like to vote for")
NumberVoted = Console.ReadLine - 1
Do Until NumberVoted >= 0 and NumberVoted <= NumberOfCandidates and NumberVoted Mod 1 = 0
Console.WriteLine("Invalid vote, please enter a whole number from 1-" & NumberOfCandidates + 1)
NumberVoted = Console.ReadLine - 1
Votes(NumberVoted) = Votes(NumberVoted) + 1
Console.WriteLine("A vote has been recorded for " & cNames(NumberVoted))
Array.Sort(Votes, cNames)
For count = 0 to numberofcandidates
Console.Writeline("Candidate: " & cNames(numberofcandidates - count))
Console.writeline("Number of votes: " & Votes(numberofcandidates - count))