Question

An application in Visual Basic that allows:

1) Enter the number of candidates in the voting.

2) Based on the number of candidates, the application should ask the name and lastname of the candidates.

3) The name of the candidates must be registered.

4) You must provide a form that allows the voting process:

a) Voting Form: The voting Form should contain the instructions for the selection of the candidate and provide a way to record each vote.

b) You must increase the sum of the votes for the corresponding candidate according to the vote.

5) As a result, the list of candidates and their total votes must be provided.

SICI 3029 Voting System Ver 1 a Voting Functions SICI Voting System 2016 Select Candidiate from the list below and press Vote System Admin Functions Voting Functions Exit System Admin Functions Vote System Admin Functions Conclude Voting Indicate Number Candidates Display Results Ist Results Enter Candidate Names Preview Candidate List Display Results Reset Candidates Back to Main Options Display Winner Back to Admin Options

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Dim Candidates() As String
Dim votes() As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
resultsList.Visible = False
candidateList.Location = New Point(143, 71)
tallyVotes.Enabled = False
resultsList.Enabled = False
Label1.Text = "Click 'Nominate Candidate' to enter a candidate, or 'Start Voting'" & vbCrLf & "to end nominations and start the voting."
End Sub
Private Sub candidateList_SelectedIndexChanged(sender As Object, e As EventArgs) Handles candidateList.SelectedIndexChanged
End Sub
Private Sub resultsList_SelectedIndexChanged(sender As Object, e As EventArgs) Handles resultsList.SelectedIndexChanged
End Sub
Private Sub nominateCandidate_Click(sender As Object, e As EventArgs) Handles nominateCandidate.Click
MessageBox.Show("When finished entering candidates, simply press enter on a blank line.", "Instructions")
Dim candidateName = InputBox("Enter the name of your candidate (first and last name please):", "Candidate Name", "", 500, 500)
Dim i As Integer = 0
Do Until String.IsNullOrEmpty(candidateName)
ReDim Preserve Candidates(i)
Candidates(i) = candidateName
i += 1
candidateName = InputBox("Enter the name of your candidate (first and last name please):", "Candidate Name", "", 500, 500)
Loop
End Sub
Private Sub startVoting_Click(sender As Object, e As EventArgs) Handles startVoting.Click
nominateCandidate.Enabled = False
tallyVotes.Enabled = True
Label1.Text = "Vote for a candidate by double-clicking his or her name." & vbCrLf & "End the voting by clicking on 'Tally Votes'."
showCandidates()
End Sub
Private Sub tallyVotes_Click(sender As Object, e As EventArgs) Handles tallyVotes.Click
resultsList.Visible = True
candidateList.Location = New Point(14, 71)
getResults()
End Sub
Private Sub candidateList_DoubleClick(sender As Object, e As EventArgs) Handles candidateList.DoubleClick
Try
votes(candidateList.SelectedIndex) += 1
candidateList.SelectedIndex = -1
Catch exc As IndexOutOfRangeException
MessageBox.Show("Please click on a candidate to vote.", "Attention!")
End Try
End Sub
Sub showCandidates()
Dim query = From candidate In Candidates
Let firstName = candidate.Split(" "c)(0)
Let lastName = candidate.Split(" "c)(1)
Let name = firstName & " " & lastName
Order By lastName
Select name
For Each Name As String In query
candidateList.Items.Add(Name)
Next
ReDim Preserve votes(candidateList.Items.Count - 1)
End Sub
Sub getResults()
For Each i In votes
resultsList.Items.Add(i)
Next
Dim mostVotes As Integer = 0
For Each item In resultsList.Items
If item > mostVotes Then
mostVotes = item
End If
Next
resultsList.SelectedItem = mostVotes
candidateList.SelectedIndex = resultsList.SelectedIndex
Dim winner = candidateList.SelectedItem
MessageBox.Show("The winner is " & winner)
End Sub

Add a comment
Know the answer?
Add Answer to:
An application in Visual Basic that allows: 1) Enter the number of candidates in the voting....
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • in python, please provide code that can be edit. Create software for a full-service voting machine....

    in python, please provide code that can be edit. Create software for a full-service voting machine. The user (voter) supplies a voter ID and the candidate he is voting for. The program checks for The user is a registered voter, by comparing the user's voter ID to a list of valid voter IDs The user has not already voted, by comparing the user's voter ID to a list of voter IDs of people who have already voted The user is...

  • Write a program that supports the three phases (setup, voting and result-tallying) which sets up and...

    Write a program that supports the three phases (setup, voting and result-tallying) which sets up and executes a voting procedure as described above. In more details: You can start with the given skeleton (lab6_skeleton.cpp). There are two structures: Participant structure, which has the following members: id -- an integer variable storing a unique id of the participant (either a candidate or a voter). name -- a Cstring for storing the name of the participant.. hasVoted -- a boolean variable for...

  • (2 bookmarks) In JAVA You have been asked to write a program that can manage candidates...

    (2 bookmarks) In JAVA You have been asked to write a program that can manage candidates for an upcoming election. This program needs to allow the user to enter candidates and then record votes as they come in and then calculate results and determine the winner. This program will have three classes: Candidate, Results and ElectionApp Candidate Class: This class records the information for each candidate that is running for office. Instance variables: first name last name office they are...

  • COSC 1437 C++ Project Assignment 2 Poll Summary Utilize a dynamic array of structure to summarize...

    COSC 1437 C++ Project Assignment 2 Poll Summary Utilize a dynamic array of structure to summarize votes for a local election Specification: Write a program that keeps track the votes that each candidate received in a local election. The program should output each candidate’s name, the number of votes received, and the percentage of the total votes received by the candidate. Your program should also output the winner of the election. To solve this problem, you will use one dynamic...

  • Please post following code with criteria below... please leave as many comments as possible Exam Four:...

    Please post following code with criteria below... please leave as many comments as possible Exam Four: the election Outcome: Student will demonstrate all core competencies from this class: Program Design (design tools) Variables Decision Error Checking Looping Functions Arrays Program Specifications: Let’s pretend that we are tracking votes for the next presidential election. There will be two candidates: Ivanka Trump and Michele Obama. You can assume that there are fifty states casting votes. You will do not need to deal...

  • You are to write a basic fitness application, in C++, that allows the user of the...

    You are to write a basic fitness application, in C++, that allows the user of the application to manually edit “diet” and “exercise” plans. For this application you will need to create three classes: DietPlan, ExercisePlan, and FitnessAppWrapper. Diet Plan Attributes: The class DietPlan is used to represent a daily diet plan. Your class must include three data members to represent your goal calories (an integer), plan name (a std::string), and date for which the plan is intended (a std::string)....

  • Java Inventory Management Code Question

    Inventory ManagementObjectives:Use inheritance to create base and child classesUtilize multiple classes in the same programPerform standard input validationImplement a solution that uses polymorphismProblem:A small electronics company has hired you to write an application to manage their inventory. The company requested a role-based access control (RBAC) to increase the security around using the new application. The company also requested that the application menu must be flexible enough to allow adding new menu items to the menu with minimal changes. This includes...

  • Visual Basic 2015: Extra 18-1 Use inheritance with the Inventory Maintenance Application Source Code: 1. frmNewItem.vb...

    Visual Basic 2015: Extra 18-1 Use inheritance with the Inventory Maintenance Application Source Code: 1. frmNewItem.vb Public Class frmNewItem Public InvItem As InvItem Private Sub frmNewItem_Load(sender As Object, e As EventArgs) Handles MyBase.Load Me.LoadComboBox() End Sub Private Sub LoadComboBox() cboSizeOrManufacturer.Items.Clear() If rdoPlant.Checked Then cboSizeOrManufacturer.Items.Add("1 gallon") cboSizeOrManufacturer.Items.Add("5 gallon") cboSizeOrManufacturer.Items.Add("15 gallon") cboSizeOrManufacturer.Items.Add("24-inch box") cboSizeOrManufacturer.Items.Add("36-inch box") Else cboSizeOrManufacturer.Items.Add("Bayer") cboSizeOrManufacturer.Items.Add("Jobe's") cboSizeOrManufacturer.Items.Add("Ortho") cboSizeOrManufacturer.Items.Add("Roundup") cboSizeOrManufacturer.Items.Add("Scotts") End If End Sub Private Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click If IsValidData() Then InvItem = New InvItem(CInt(txtItemNo.Text),...

  • InventoryManagement

    Problem:A small electronics company has hired you to write an application to manage their inventory. The company requested a role-based access control (RBAC) to increase the security around using the new application. The company also requested that the application menu must be flexible enough to allow adding new menu items to the menu with minimal changes. This includes re-ordering the menu items and making changes to the description of a menu item without having to change the code.Security:The company has...

  • Edit a C program based on the surface code(which is after the question's instruction.) that will...

    Edit a C program based on the surface code(which is after the question's instruction.) that will implement a customer waiting list that might be used by a restaurant. Use the base code to finish the project. When people want to be seated in the restaurant, they give their name and group size to the host/hostess and then wait until those in front of them have been seated. The program must use a linked list to implement the queue-like data structure....

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT