G22.2110-001  Programming Languages

Homework 2 -- Due May 31

In this assignment you will write a simple electronic voting machine in Ada.

  1. Write a 'main' procedure that displays an enumerated list of candidates and allows you to "vote" for one of the candidates by entering your name and  the number of the candidate for whom you are voting. The procedure should loop indefinitely so that everyone who wants to gets a chance to vote.
  2. Write a package to support the voting procedure. Your package should provide the following services:
    1. Provide a list of  candidate names
    2. Accept a vote (as an index into the list of candidate names)
    3. Record the number of  votes for each candidate
    4. Prevent the same person from voting twice
    5. Provide the vote totals for each candidate (your main proc will have to have a way to request this)
    So, given a list of 4 candidates,  a session might look like this(you don't have to use exactly this format as long as the above requirements are met) :
       
        Candidates:  1 Fred, 2 Ethel, 3 Ricky, 4 Lucy
        Vote Now? (Y or N): 
Y
        Enter Your Name:  Desi
        Select your candidate:   3
      
        Candidates:  1 Fred, 2 Ethel, 3 Ricky, 4 Lucy
        Vote Now? (Y or N):  Y
 
       Enter Your Name:  Lucillei
        Select your candidate:   4
     
        Candidates:  1 Fred, 2 Ethel, 3 Ricky, 4 Lucy
        Vote Now? (Y or N):  N
        Show Totals? (Y or N):  Y   
          1 Fred   0
          2 Ethel  0
          3 Ricky 1
          4 Lucy   1
       
        Candidates:  1 Fred, 2 Ethel, 3 Ricky, 4 Lucy

        Vote Now? (Y or N):  N
        Show Totals? (Y or N):  N
        Quit Now? (Y or N):  Y