Essay, Logic and programming
Simple voting machine in Java
7
Project description
In this exercise you will create a simple VotingMachine. In the United States, when a candidate runs for office, the person is often identified as a Democrat,
Republican, or Independent. Write a Java class (VotingMachine.java) which allows one to vote by party affiliation and will also allow us to query the number of votes
for each party and who won the election. The behavior is given below:
VotingMachine vm = new VotingMachine();
vm.voteDemocrat();
vm.voteDemocrat();
vm.voteRepublican();
vm.voteIndependent();
vm.countDemocrat(); // returns 2
vm.countRepublican(); // returns 1
vm.countIndependent(); // returns 1
vm.whoWon(); // returns Democrat
NOTE: For simplicity, you may assume that there will be no ties in this election.
35
Paper instructions:
Post the name or position’ of a contemporary leader (or leading company) and list the accomplishments that qualify them as a leader. You may politely question,
challenge or argue someone’s posting. Hint: Use the name of the subject in your written assignment for the week.