CMPS 1043 – Program 5 – Fall 2011 – Presidential Primaries DUE: Tuesday, October 18 & Wednesday, October 19 Begin testing with your own data or the sample data below. The data set to be turned in will be posted on the web site. As you may or may not know, the U.S. Government has mandated that electronic voting equipment be used for all elections. Thus, software which presents election ballots is necessary. If you have voted in a recent election, you have probably seen examples of these systems. There are many companies providing such software and terminals. All of those used today are stand-alone terminals. This is not Internet voting. In this project, you will develop a small computer-based voting system for the upcoming primary elections. You must follow the specifications exactly. Begin by getting the program running on the screen. Then ADD copies of all cin and cout commands as outfile commands so that a file will be produced that looks EXACTLY like the screen for me to grade. All input will be from the keyboard because this is an electronic voting system. Your program will be for the primary election. Thus, first you will ask if they want to vote in the Democratic Primary or the Republican Primary. If they select Democratic, you will display the list of Democratic Candidates. If they select Republican, you will display the list of Republican candidates. The voter will then select one of the candidates by typing the number by the candidate’s name. You will maintain a count of the votes for each candidate. You may assume that the user will always enter the correct data. You must us an if-else statement to process the choice of Democrat, Republican, or End election. You must use switch statements to process the menu selections and count the votes. At the end of the election, you will print out two reports – one for the Democratic Primary and one for the Republican Primary. The reports will print the name of each candidate and the total number of votes. Then will print the name of the winner (the one with the most votes). The program will stop when the user selects “End Election” from the menu. You must print the menu for each new voter!!! The format of your output must be VERY similar to what is shown on the next page. NOTE: This program will be VERY LONG!!! However, you will be able to copy and paste quite a bit of the code that is similar for both parties, etc. HINT: USE THE METHOD OF INCREMENTAL DEVELOPMENT: Start by getting the program working for only one party and list only 3 candidates. Test with several sets of data and ensure it is working properly. Then add all the candidates and test again. Now add the second party and test again. Ta-daa! You will have a working program! **THIS IS WHAT YOUR OUTPUT ON THE PAPER SHOULD LOOK LIKE.** Your name here! // print your name only once at the very beginning! Welcome to the Presidential Primary Election 2011! Would you like to vote in the Democratic Primary or the Republican Primary? Please enter the corresponding number. 1. Democratic 2. Republican 3. End Election You selected the Democratic Primary. -------------------------------------------------------------------------------------------------// Depending upon the selection, continue with the following menus. // This is for the Democratic Party. Thank you for choosing the Democratic Primary. Please vote for ONE of the following candidates. Please enter the corresponding number. 1. Barak Obama 2. Joseph Biden 3. Hillary Clinton 4. Nancy Pelosi You selected Joseph Biden. ------------------------------------------------------------------------------------------------------// This is for the Republican Party. Thank you for choosing the Republican Primary. Please vote for ONE of the following candidates. Please enter the corresponding number. 1. 2. 3. 4. 5. 6. 7. 8. 9. Rick Perry Sarah Palin Michele Bachman Herman Cain Chris Christi Ron Paul Mitt Romney Jeb Bush Newt Gingrich You selected Mitt Romney. // Sample Final Report – do one for both parties. ---------------------------------------------------------------------------------------------The Results of the Democratic Presidential Primary: Barak Obama Joseph Biden Hillary Clinton Nancy Pelosi 503022 45302 501989 9345 The Winner is Barak Obama with 503022 votes. -----------------------------------------------------------------------------------------------The data file which will be provided to you to process will be as follows, where the number indicates Democratic Primary (1) and Republican Primary (2) and the name indicates the person receiving the vote. The 3 indicates the end of the file. (You can use this data as a test file but the file to be used for turning is will be longer and will be posted on the class website. 2 2 1 1 1 2 2 2 2 1 2 2 1 2 2 2 2 2 2 3 Michele Bachman Michele Bachman Barak Obama Hillary Clinton Nancy Pelosi Sarah Palin Ron Paul Mitt Romney Jeb Bush Nancy Pelosi Rick Perry Sarah Palin Joseph Biden Michele Bachman Chris Christi Ron Paul Mitt Romney Jeb Bush Newt Gingrich