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:

  1. 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].

  2. 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'.

 the goal is to write a C++ function that will provide

* Predict the winner of an election among three parties, using a weighted * aggregation of historic polls. * @param[in] a * @param[in] b * @param[in] C * @param[in] pollWeights how much weight is placed on each poll the poll-by-poll results for Party A [%] the poll-by-poll results for Party B [%] the poll-by-poll results for Party C [%] Opre sum of pollWeights is 1 * @param[out] *@param *ereturns resultspoll-by-poll expected winner len overall predicted winner ('A, B' or 'C) @post every element in result is A Bor 'C length of all arrays passed to the function char predictWinner (const double a[], const double b[l, const double c[l, const double pollWeights[], char results[], int len): * Predict the winner of an election among three parties, using a weighted * aggregation of historic polls. * @param[in] a * @param[in] b * @param[in] C * @param[in] pollWeights how much weight is placed on each poll the poll-by-poll results for Party A [%] the poll-by-poll results for Party B [%] the poll-by-poll results for Party C [%] Opre sum of pollWeights is 1 * @param[out] *@param *ereturns resultspoll-by-poll expected winner len overall predicted winner ('A, B' or 'C) @post every element in result is A Bor 'C length of all arrays passed to the function char predictWinner (const double a[], const double b[l, const double c[l, const double pollWeights[], char results[], int len)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!