Code a complete Java program based on the following specs. Part I: (required) You have been asked to design a modular program that willrecap the election results for a made-up election for a made-up...


Code a complete Java program based on the following specs.


Part I: (required)


You have been asked to design a modular program that willrecap the election results for a made-up election for a made-up position


You must use JOptionPane for all your input, output, and confirmation.


-You are given 3 sets of information:


--an array of 5 candidates last names.


Candidates: “Trump”, “Clinton”, “Scott”, “Hillary”, “Kerry”


--an array of their party affiliation coded as R for Republican, D for Democrat, and I for Independent.


Party : ‘R’ , ‘D’ , ‘R’ , ‘D’ , ‘D’


--an empty array to hold votes for each candidate.


Votes : 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0


Hints: candidate: string, party: char, votes: int


-your program should prompt the user if he/she wants to start this program or quit early.


-if the user chooses to start program, then prompt the user with a menu similar to the following:


---1-Vote


---2-Search for candidate


---3-Display All Candidates -(name, party ,total votes)


---4-Quit


Implement the menu as a separate function


-Implement a function for each of the menu items.


-if user select option 1 (Vote) then prompt the user to enter a candidate name, validate the name by coding a function for this process, search for the candidate in the array, and if found, prompt the user to confirm his/her vote for this candidate, add 1 to his/her tally of votes in the corresponding entry in the array of votes. If candidate is not found then prompt the user again to re-enter another candidate.


-repeat again by displaying the menu for another voter.


-if user chooses 2 then prompt the user to enter a name for a candidate, call a function to search for it and if found display all the info. About this candidate.


-when user select 3, make sure you display all candidates, their political affiliation (spell out the affiliation Republican for R, Democrat for D, and Independent for I, and their total number of votes.


-If user select 4 (Quit) close the voting by automatically selecting option 2 (display all), the winner (name, affiliation, total votes, and quit with a suitable message


-Make sure you validate all input. Add a function for each type of validation.


Part II: redesign your program, this time, implement the following menu options: (you must submit a separate program for the extra credits)


-1-add a new candidate


-2-start the voting


-3-search for a candidate


-4-Quit


Your parallel arrays must be of size 20 and all empty. Do not allow voting or search if no candidate is added. Only start the election if you have a minimum of 3 candidates.

Aug 10, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here