Trying to figure out a Polling program. The program has 5 questions that get asked to upto 10 users. You rank the questions by importance, 1 - 10. At the end the program is supposed to tally up the totals of each question from all of the users and display it in a table form. Supposed to be 5 rows with 10 columns array where each row pertains to each of the 5 questions asked and the 10 columns are the possible rankings from 1 to 10. Ideally the results should look like this.
Whatever Question 1 is?
1 2 3 4 5 6 7 8 9 10 Average
0 3 4 0 0 0 1 0 0 2 (the average)
Whatever Question 2 is?
Etc.....
So far I have the code to write the questions, just stuck on how to create a function to tally up and display the results. Any insight or help on this would be greatly appreciated. Here is the code I have
#include <iostream>
#include <string>
#include <array>
usingnamespace std;
void Results(int Answer1);
int main()
{
char Done;
char Calculate;
int Respondant = 0;
int TopicNumber = 0;
cout << "Welcome to Chris Simonson's Polling Application" << endl;
cout << endl;
cout << "Enter 'done' to terminate application or enter any other character to continue -> ";
cin >> Done;
cout << endl;
if (Done == 'd'){
cout << "Program Terminating" << endl;
return 0;
}
else {
string topics[5]{"How important is reducing the federal debt and deficit? ",
"How important is protecting American workers from low wages? ",
"How important is a strong national defense? ",
"How important is eliminating unfunded government entitlements? ",
"How important are public educational opportunities? "};
int FinalAnswer[5][10];
for (Respondant = 0; Respondant < 10; Respondant++){
cout << "Hello Respondent " << Respondant + 1 << endl;
cout << endl;
cout << "This poll rates peoples' opinions on five social issues." << endl;
cout << endl;
cout << "Please rate the importance of an issue to you by entering a number from 1 (minimum importance) thru 10 (utmost importance)." << endl;
cout << endl;
for (TopicNumber = 0; TopicNumber < 5; TopicNumber++){
cout << TopicNumber + 1 << ": " << topics[TopicNumber];
cin >> FinalAnswer[TopicNumber][10];
cout << endl;
cout << endl;
}
cout << "Enter 'done' to end poll and calculate results or enter any other character to continue with next respondent -> ";
cin >> Calculate;
cout << endl;
if (Calculate == 'd'){
Results(Answer1);
break;
}
}
}
}
void Results(int Answer1){
cout << "HERE ARE THE RESULTS =============================" << endl;
cout << endl;
cout << "Thank you for participating in this poll. Program terminating........" << endl;
}
Not quite sure how to do that. This is my first programming course and the extent of what we have learned has been pretty basic, classes, loops, counters and briefly arrays. The assignment asks for a 5 row 10 column array. I do get how to make the array, but am unsure how to take the answers to all 5 questions from each user and tally them up to display what I have above. If its possible to do a matrix with arrays that would work but am pretty unsure how to do that. Thanks for the help in advance. Even pointing me in the right direction will help since I have done tons of research and videos on arrays and still just am lost.