Vous êtes sur la page 1sur 2

CSc 101N 2nd Major Exam (Hands On)

Electronic Presidential Election Voting Program


Electronic Presidential Election Voting Program covers the following modules:
Voting module
Shows the unofficial result of the election
These are the 5 official presidential candidates:
#1 Joselito W. Mariano
#2 Consuelo L. Ramonal
#3 Myrna C. Luzado
#4 Gilbert O. Yroila
#5 Constancia R. Ramos
A voter is allowed to select one candidate using the candidates corresponding number. He can also view the unofficial result of
the election.
The unofficial result shows the statistics. The list of candidates is sorted according to the number of votes, in percentage, a
candidate garnered. The highest number of votes is placed first in the list. This is the formula to get the percentage value of
100
votes per candidate: =
. The total number of voters dynamically changes

from time to time while there are still voters to cast a vote.
Suppose the current number of voters is 11 with the following distribution,
#1 Joselito W. Mariano got 3 votes
#2 Consuelo L. Ramonal got 1 vote
#3 Myrna C. Luzado got 6 votes
#4 Gilbert O. Yroila got 1 vote
#5 Constancia R. Ramos got 0 vote
This is the sample dialog of the Electronic Presidential Election Voting Program:
[ 1 ] VOTE
[ 2 ] UNOFFICIAL RESULT
[ 3 ] CLOSE ELECTION
Select an option: 1
OFFICIAL PRESIDENTIAL CANDIDATES
-------------------------------------------------(1) Joselito W. Mariano
(2)Consuelo L. Ramonal
(3) Myrna C. Luzado
(4)Gilbert O. Yroila
(5) Constancia R. Ramos
Select a candidate: 3
You voted Myrna C. Luzado
Thank you for voting!
[ 1 ] VOTE
[ 2 ] UNOFFICIAL RESULT
[ 3 ] CLOSE ELECTION
Select an option: 2
UNOFFICIAL PRESIDENTIAL ELECTION RESULT
------------------------------------------------------------#3 Myrna C. Luzado 58.33%
#1 Joselito W. Mariano 25%
#2 Consuelo L. Ramonal 8.33%
#4 Gilbert O. Yroila 8.33%
#5 Constancia R. Ramos 0%
[ 1 ] VOTE
[ 2 ] UNOFFICIAL RESULT
[ 3 ] CLOSE ELECTION
Select an option: 3
The election is officially closed!

Create this program with the following requirements:


Create an abstract class Person with the following:
o Attributes
First name
Middle initial
Last name
o Empty Constructor
o Accessor and Mutator Methods of the attributes
Create a class Candidate that inherits the Person class with the following:
o Attributes
Candidate number
Number of votes
o Empty Constructor
Accessor and Mutator Methods of the attributes
Create a program driver to start constructing Electronic Presidential Election Voting Program using the Candidate
class created.
Create an interface name MethodsInterface. And let the Candidate class implement the methods. These are the
following:
o A method name sortCandidate(Candidate listOfCandidate[ ]), with the candidateList as the parameter, that
sorts the array list of candidates according to the highest number of votes
o A method name computePercent(int numberOfVotesPer, int numOfVoters), with number of votes per
candidate and the total number of voters as parameters, that computes and returns the percentage value of
votes per candidate
These methods will be used in the program driver under the class Candidate.
All 5 candidates are stored in an array name candidateList in your program driver.

Vous aimerez peut-être aussi