Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Using Visual Basic The members of a club bring a computer to their annual meetin

ID: 3766573 • Letter: U

Question

Using Visual Basic

The members of a club bring a computer to their annual meeting to use in the election of a new president. Write a program to handle the election. (See figure). When the program is first run, the lable at the top of the page should read as folloes: Click "Nominate Candidate" to enter a candidate, or "Start Voting" to end nominations and start the voting. The program should add each candidate to a list box as he or she is nominated. After the nomintation process is complete, club members should be able to approach the computer one at a time and double-click on the candidate of their choice. When the Tally Votesbuton is clicked on, a second list box, showing the number of votes received by each candidate, should appear along side the first list box. Also, the name(s) of the candidate(s) with the highest number of votes should be displayed in a message box.

Voting Vote for a candidate by double-clicking on his/her name. End the voting by clicking on 'Tally Votes' Mike Smith David Williams John Miller Maria Garcia 3 votes 4 votes 1 vote 6 votes Nominate CandidateVoting Tally Votes Start FIGURE 9,68 Posible outcome of Programming Project 2.

Explanation / Answer

sub main()

'Variables declaration
Dim N as integer=5
Dim name[] as String
dim count[4] as integer
dim numOfClubMembers as integer=10
dim i as integer
dim ch as integer

end sub


sub form_Load()
label1.visible=true
label2.visible=false
label1.text=" Click Nomianate Candidate to enter a candidate , or Start Voting to end nominations and start the voting"
list1.visible =false
list2.visible=false
end sub


private sub NominateCandidateButton_click()
for i=1 to N do
name[i]=text1.text
list1.add(name[i])
end for
end Sub

private sub StartVotingButton_click()
label2.text="Vote for a candidate by double-clicking on his/her name. end the voting by clicking on Tally votes."
label2.visible=true
NominateButton.enable=false
list1.visible=true
for i=1 to numOfClubMembers do
ch=list1.getselectedIndex();
Select Case ch
Case Is 1
count[1]=count[1]+1
Case Is 2
count[2]=count[2]+1
Case Is 3
count[3]=count[3]+1
Case Is 4
count[4]=count[4]+1
end Select
end for
End sub

//tally
private sub TallyVotesButton_click()
Dim str as String=""

int max=count[0];
for i=1 to N do
if(count[i]>max) then
max=count[i]
end if
end for

for i=1 to N do
list2.addItem(count[i]+"votes")
end for
list2.visible=true

for i=1 to N do
if (count[i]==max) then
str+=name[i]+"-----> "+max+" "
end if
end for

MsgBox("Candidate(s) with highest vote"+str)

End sub

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote