Polling Application

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
  #include <iostream>
#include <string>
#include <array>
using namespace 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;
	
}
Last edited on
How about you print them in form of matrix(just like score card)?
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.
Topic archived. No new replies allowed.