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
If everything is valid the vote is counted and added to a total for the specified candidate
If the user is not a registered voter he can register to vote. This adds his name to the registeredVoter list and makes it immediately possible for him to vote
At the end of the voting period, the winning candidate is announced along with the total number of votes for that candidate and the total number of votes for all candidates
#voting_machine.py
#function that generates voter ids from starting to ending
range
#voter id format VOXXXX --> where X is the digit
def generateVoters(start_range, end_range):
voters = []
for i in range(start_range, end_range):
pre = "VO"+str(i)
voters.append([pre,1])
return voters
#function to print candidates
def print_candidates(candidates):
print("*****************************\n")
print(" Welcome to 2019 Elections\n")
print("Participating Candidates are:\n")
for i,cand in enumerate(candidates):
print(i+1,".",cand[0].title())
print("\n*****************************\n")
#function that returns given voter is valid
#voter is already voter or not
def validate_voter(voters,voter):
#for each voter in voters list
for i in range(len(voters)):
#if voter passed is present in
voters list
if(voters[i][0] == voter):
#if voter is not
already voted return index of i
if(voters[i][1]
== 1):
return i
#else return 2 ,
which stands for already voted
else:
return -2
#if voter not present return 0
return -1
def validate_cand(candidates, cand):
#for each candidate
for i in range(len(candidates)):
#find if candidate passed is equal
to the candiates in list
#return index of candidate in
list
if(candidates[i][0] == cand):
return i
#return -1 if candidate is not present
return -1
#FUNCTION that finds the winner among the candidates
def find_winner(candidates):
#intial max votes and max votes candidate index in
list
max_votes = 0
cand_ind = -1
#for each candidate find max votes and index of the
candidatesh/h
for ind in range(len(candidates)):
votes = candidates[ind][1]
if(max_votes < votes):
max_votes =
votes
cand_ind =
ind
#check for tied candidates
count = 0
#intially put candidate with max votes find
above
tied_cands = [candidates[cand_ind]]
for i in range(len(candidates)):
votes = candidates[i][1]
#if candidate is not the one find
in above for loop
#with same number of max votes add
it to the tied cands array
if(votes == max_votes and i !=
cand_ind):
count += 1
tied_cands.append(candidates[i])
#return the candidates tied
return tied_cands
voters = generateVoters(1000,1200)
candidates = [["joe biden",0],["kamala harris",0],["bernie
sanders",0],["bill de blasio",0],["elizabeth warren",0]]
voter = 0
choice = ""
while(choice.upper() != "Q" ):
print_candidates(candidates)
voter = input("\nEnter Voter Id:
").strip().upper()
ind = validate_voter(voters, voter)
if(ind >= 0):
cand = input("Enter Candidate Name
you Wish to Vote for: ").strip().lower()
cand_ind =
validate_cand(candidates,cand)
if(cand_ind == -1):
print("Invalid
Candidate Name Entered")
else:
candidates[cand_ind][1] += 1
voters[ind][1] =
0
elif(ind == -2):
print("Voter with voter
Id:",voter," is Already Voted")
else:
print("Invalid Voter Id
Entered")
choice = input("\nEnter Q to Quit or any key to
continue: ").strip()
cand = find_winner(candidates)
print("\n")
if(len(cand) == 1):
print("*****************************\n")
print("Winner of Election
is:",cand[0][0].title(),"With",cand[0][1],"votes.")
print("\n*****************************\n")
else:
print("\n*****************************\n")
print("Candidates are tied
with",cand[0][1],"Votes.")
print("Tied Candidates are:")
for cands in cand:
print(cands[0].title())
print("\n*****************************\n")
in python, please provide code that can be edit. Create software for a full-service voting machine....
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 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...