Programming Assignment 18

 

 

            The results from the Oneonta mayoral race have been reported by each precinct as follows:

 

                   Candidate

               A   B   C   D

     Precinct  ---  ---  ---  ---

        1      192   48  206   37

        2      147   90  312   21

        3      186   12  121   38

        4      114   21  408   39

        5      267   13  382   29

 

 

Write a program to do the following:

 

1.         Read in and print out the table with appropriate headings.

 

2.         Compute and print out the total numbers of votes received by each candidate.  Also compute and print out the percentage of votes received by each candidate.

 

     Candidate     Votes     Percent

        A          XXX        XX%

        B          XXX        XX%

       etc.          etc.       etc.

 

3.         If one candidate received over 50% of the votes, declare him or her the winner. 

            Otherwise declare that there is no winner.