Question
the goal is to write a C++ function that will provide a simplified form of poll aggregation. You will be given four arrays, all of
the goal is to write a C++ function that will provide a simplified form of poll aggregation. You will be given four arrays, all of the same length, representing:
-
the polling history for Party A (numbers between 0 and 100%),
-
the polling history for Party B (numbers between 0 and 100%),
-
the polling history for Party C (numbers between 0 and 100%) and
-
the weight that should be given to each poll.
These four arrays correspond to columns on the Calculated Politics website(https://www.calculatedpolitics.com/project/2019-canada-election/). For example, the polling results for Week 3 of an election campaign are found at index 3 in each of the first three arrays; the importance of that poll is found at index 3 of the fourth array. Given this information, your function should do two things:
-
Compare the poll-by-poll results and store a character for the leading party in a fifth array that will be provided to you. For example, if partyA[3] is greater than partyB[3] and partyC[3], you should store an 'A' character in results[3].
-
Calculate an overall result using a weighted sum of each partys results. For example, if the weighted sum of party As results is higher than that of parties B and C, your function should return an 'A'.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started