QUESTION
UNi-Library is conducting a survey to rate the quality of their services in order to improve their
services. In the survey, 30 students were asked to rate the quality of the service in the library on a
scale of 1 to 5 (1 indicating very bad and 5 indicating excellent). You have to store the 30 responses of
the students in an array named responses [ ]. Then, you have to count the frequency of each scale
and store it in an array named frequency[ ]. Use the appropriate looping structure to enter the
responses and to count the frequency. You are also required to display the percentage of the
frequency of each scale. Display the scale, frequency and its percentage as shown below.
The program also allows the user to repeat this process as often as the user wishes.

*Write a complete C++ program*​

QUESTIONUNiLibrary is conducting a survey to rate the quality of their services in order to improve theirservices In the survey 30 students were asked to rate t class=

Respuesta :

Answer:

Explanation:

#include <iostream>

using namespace std;

int main ()

{

   int responses[30],count[6];

   int score = 0;

   string resp = " ";

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

   {

    responses[i] = 0;

   }

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

   {

    count[i,1]=0;

    count[i,2]=0;

    count[i,0]=0;

   }

   while ((resp != "Y") && (resp != "y"))

   {

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

    {

        while ((score > 5) || (score < 1))

           {

            cout << "Student " << (i+1)<< " please enter a value (1-5):";

            cin >> score;

        }

           responses[i] = score;

           if((score > 5)||(score<1))

           {

               if(score==1) count[1]++;        

               if(score==2) count[2]++;        

               if(score==3) count[3]++;        

               if(score==4) count[4]++;        

               if(score==5) count[5]++;        

           }

           score = 0;

    }

    cout<< "Response               Frequency              Percentage"<<endl;;

    cout<< "    1                      "<<count[1]<<"               "<<(count[1]/30)<<"%"<<endl;

    cout<< "    2                      "<<count[2]<<"               "<<(count[2]/30)<<"%"<<endl;

    cout<< "    3                      "<<count[3]<<"               "<<(count[3]/30)<<"%"<<endl;

    cout<< "    4                      "<<count[4]<<"               "<<(count[4]/30)<<"%"<<endl;

    cout<< "    5                      "<<count[5]<<"               "<<(count[5]/30)<<"%"<<endl;

    cout<< "Do you want to exit? Press Y to exit any other key to continue: ";

    cin>> resp;

   }

   return 0;

}