Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ programming Instructions The Internet and the web enable people to network,

ID: 3723872 • Letter: C

Question

C++ programming Instructions The Internet and the web enable people to network, join a cause, and so on. The presidential candidates in 2012 used the Internet to get out their messages and raise money. In this exercise, you'll write a polling program that allows users to rate five social-consciousness issues from 1 to 10 (most important).Pick five causes (e.g, political issues, global environmental issues). Use a one dimensional string array topics to store the 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. Generate random responses. 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. Submission Please only submit your *h and *cpp files NOTE-You need to Upload your files and then Submit them. The TAs will have no access to your files if you forget to submit them

Explanation / Answer

file polling.cpp

#include <iostream>

#include <stdlib.h>

#include <time.h>

using namespace std;

int main(int argc, char const *argv[])

{

string causes[5];

causes[0] = "Economic Reforms";

causes[1] = "Environmental Reforms";

causes[2] = "Gun Control";

causes[3] = "Education";

causes[4] = "Foreign Policy";

int responses[5][10];

for(int i = 0 ; i < 5 ; i++)

{

cout<<"Rate [from 0-10] issue number "<<i<<": "<<causes[i]<<" ";

cin>>responses[i][0];

}

srand (time(NULL));

for(int j = 1 ; j < 10 ; j++)

{

for(int i = 0 ; i < 5 ; i++)

{

responses[i][j] = (rand() % 10) + 1;

}

}

int highest_rated_issue;

int highest_rating_total = -1;

int lowest_rated_issue;

int lowest_rating_total = 110;

int sum;

for(int i = 0 ; i < 5 ; i++)

{

sum = 0;

cout<<causes[i]<<" ";

for(int j = 0 ; j < 10 ; j++)

{

sum = sum + responses[i][j];

cout<<responses[i][j]<<" ";

}

if(sum > highest_rating_total)

{

highest_rated_issue = i;

highest_rating_total = sum;

}

if(sum < lowest_rating_total)

{

lowest_rated_issue = i;

lowest_rating_total = sum;

}

cout<<"average: "<<sum/10.0<<endl;

}

cout<<"Highest rated issue is "<<causes[highest_rated_issue]<<" with total points "<<highest_rating_total<<endl;

cout<<"Lowest rated issue is "<<causes[lowest_rated_issue]<<" with total points "<<lowest_rating_total<<endl;

return 0;

}

// Instructions to compile and run

// compile by running g++ -o polling polling.cpp in your terminal

// run using ./polling in your terminal

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote