This week, we'll be looking at how approval ratings work for political polls. I've attached a file that contains the results of a fictional Gallup poll about the approval rating for the president. The file contains the information for 100 people, including the person's name, party, income and rating. Since politial analysts are always interested in demographics (a demographic is a certain group of people), your job this week is to compute the approval ratings for a few different demographics. The groups of people that were interested in are those that are Republicans vs Democrats, and those people that make more or less than 30,000 dollars per year. Since we'll be looking at 2x2 different groups, there will be 4 total demographics that we look at. For each demographic, richer Democrats, poorer Democrats, richer Republicans, and poorer Republicans, you'll compute the AVERAGE approval rating for the president. Recall that the average is computed by adding up the total of all the ratings for a group and then dividing by the number of people that you included in the group. Your program should work as follows. First, you need to prompt for and input a file path to the poll file. Next, you'll check to make sure that the file at that path opened correctly. If not, please report an appropriate error message and quit the program. Then, echo the contents of the file to the screen. Finally, display the averages for each of the four demographics required. The numbers you're looking for are: Republicans under $30000: 51% Republicans over $30000: 65% Democrats under $30000: 40% Democrats over $30000: 45% Notice that the numbers in the file are from 0-5 (since the question for the poll is worded as "strongly approve, approve, slightly approve, slightly disapprove, disapprove, or strongly disapprove") but our numbers are percentages from 1-100. To convert from the range from 0-5 to a percentage, simply multiply the result by 20.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here