Dim numberofstudents as integer
Dim Numberofcandidates as integer
Dim Candidatename(4) as string
Dim Candidatevote(4) as integer
Dim UniqueNumberCheck(35) as string
Dim indexofNumber as integer
Dim totalvotes as integer
dim tempPercentage as string
Dim winningCandidateCount as integer
Dim tiedCandidatesNames(4) as string
Console.WriteLine("Enter name of Tutor Group")
GroupName = console.readline()
Console.WriteLine("Enter number of students")
Do While Not (Integer.TryParse(temp, Numberofstudents) AND Numberofstudents >= 28 AND Numberofstudents <= 35)
Console.writeline ("Enter a whole number between 28 and 35")
temp = console.ReadLine()
Console.WriteLine("Enter number of candidates in the election")
Do while Not (Integer.TryParse(temp, Numberofcandidates) AND Numberofcandidates >= 1 AND Numberofcandidates <= 4)
Console.writeline ("Enter a whole number between 1 and 4")
temp = console.ReadLine()
For n = 1 To Numberofcandidates
Console.WriteLine("Enter name of candidate " & n)
Candidatename(n) = console.readline
Candidatename(0) = "Abstain"
tiedCandidatesNames(n) =""
WinningCandidateCount = 0
do while n < numberofstudents
Console.WriteLine("Please enter your unique voter number")
testnumber = console.ReadLine()
if UniqueNumberCheck(n) = testnumber then
If indexofnumber > 0 then
Console.WriteLine("You have already voted")
UniqueNumbercheck(n) = testnumber
Console.WriteLine("Student " & n & " please enter your vote;")
Console.WriteLine("Enter 0 to abstain")
for m = 1 to Numberofcandidates
console.WriteLine("Enter " & m & " to vote for " & Candidatename(m))
temp = console.ReadLine()
Do while Not (Integer.TryParse(temp, testvote) AND testvote >= 0 AND testvote <= Numberofcandidates)
Console.writeline ("Enter a whole number between 0 and " & Numberofcandidates)
temp = console.ReadLine()
Candidatevote(testvote) = Candidatevote(testvote) + 1
TotalVotes = candidateVote(1) + candidateVote(2) + candidateVote(3) + candidateVote(4)
Console.WriteLine("Tutor Group: " & GroupName)
for n = 1 To Numberofcandidates
temppercentage = cInt(CandidateVote(n) / TotalVotes * 100) & "%"
Console.WriteLine(Candidatename(n) & " got " & Candidatevote(n) & " votes (" & temppercentage & ")")
if Candidatevote(n) > Max then
Console.WriteLine("The total number of votes was " & totalVotes & " with " & CandidateVote(0) & " abstentions")
winningCandidateCount = 0
Console.WriteLine("The following candidate(s) have scored the most votes;")
For n = 1 to Numberofcandidates
if Candidatevote(n) = max then
winningCandidateCount = winningCandidateCount + 1
Console.WriteLine(Candidatename(n))
tiedCandidatesNames(winningCandidateCount) = Candidatename(n)
If winningCandidateCount > 1 then
console.WriteLine("We need to vote again due to a draw")
for n = 1 to numberofcandidates
Candidatename(n) = tiedCandidatesNames(n)
numberofcandidates = winningCandidateCount