2nd C++ assignment. Hopelessly stuck

So this is my second C++ assignment. I have spent 37 hours now watching youtube tutorials, rereading the book, typing and throwing out code. I need to get this done tonight, if there is anyone willing to help me understand this assignment I would greatly appreciate it.

In this exercise, you’ll write a simple polling program that allows users to rate five social-consciousness issues from 1 (least important) to 10 (most important). Pick five causes that are important to you (e.g., political issues, global environmental issues). Use a one-dimensional array topics (of type String) to store the five causes. To summarize the survey responses, use a 5-row, 10-column two-dimensional array responses (of type int), each row corresponding to an element in the topics array. When the program runs, it should ask the user to rate each issue. Have your friends and family respond to the survey. Then have the program display a summary of the results, including:
a) A tabular report with the five topics down the left side and the 10 ratings across the top, listing in each column the number of ratings received for each topic.
b) To the right of each row, show the average of the ratings for that issue.
c) Which issue received the highest point total? Display both the issue and the point total.
d) Which issue received the lowest point total? Display both the issue and the point total.

This is what I've gotten figured out so far. First problem, my entries store backwards. I am not sure why, there is nothing in my book or online that would indicate why that is happening. Instead of storing it in the 2D Array as ABCDE it stores as EDCBA. My second problem is that I can't figure out how to store it and then have it save in another part of the array for the next user to input data

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
  #include <iostream>
#include <string>
#include <array>

using namespace std;

int main()
{
    string topics[5]{"World Hunger", "Government Oppression", "Genocide", "Disease", "Educational Deficiencies"};

    int HiPoints = 0; 
    int LowPoints = 10;
    
    int a;
    int b;
    int c;
    int d;
    int e;
    int entries[5][10] = {{0,1,2,3,4,5,6,7,8,9},{0,1,2,3,4,5,6,7,8,9},{0,1,2,3,4,5,6,7,8,9},{0,1,2,3,4,5,6,7,8,9},{0,1,2,3,4,5,6,7,8,9}};

    cout << "Rate the importance of these topics from 1-10 (10 being most important) \n";
    cout << "1: " << topics[0] << endl;
	cout << "2: " << topics[1] << endl;
	cout << "3: " << topics[2] << endl;
	cout << "4: " << topics[3] << endl;
	cout << "5: " << topics[4] << endl;
    cout << endl;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> d;
    cin >> e;

    a == entries[4][0];

    b == entries[4][1];

    c == entries[4][2];

    d == entries[4][3];

    e == entries[4][4];

    cout << endl;
    cout << "1: " << entries[4][0] << endl;
    cout << "2: " << entries[4][1] << endl;
    cout << "3: " << entries[4][2] << endl;
    cout << "4: " << entries[4][3] << endl;
    cout << "5: " << entries[4][4] << endl;
    return 0;


}
Last edited on
closed account (D80DSL3A)
You will need to use nested for loops to gather the data and fill the array entries[5][10].

The outer loop is over the 10 poll respondents (r) and the inner loop is over the 5 topics (t). So, something like this (pseudocode):
1
2
3
4
5
6
7
8
9
for( r=0 to 9 )// for each of the 10 poll respondents
{
    cout << "Rate the importance of these topics from 1-10 (10 being most important) \n";
    for( t=0 to 4 )// for each of the 5 topics
    {
         cout << t+1 << ": " << topics[t] << ": ";
         cin >> entries[t][r];
    }
}

Then generate your table. After printing the column header line you can generate the 5 rows using nested for loops like above, but reversed so the outer for is over the 5 topics and the inner for is over the 10 rankings for that topic. You can do all calculations (finding the average rank for each topic, and the highest and lowest average rankings) within these loops as you generate the table rows.

Hope that helps.
Last edited on
Thanks a bunch!
Topic archived. No new replies allowed.