1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Elina [12.6K]
3 years ago
9

For this assignment, you will use pointers to write a program that can be used to gather statistical data about the number of mo

vies college students see in a month. The program should ask the user how many students were surveyed and dynamically allocate an array of that size. The program should then allow the user to enter the number of movies each student has seen. The program should then calculate the average, median, and mode of the values entered. Be sure to include comments throughout your code where appropriate.
Complete the C++ code
Computers and Technology
1 answer:
salantis [7]3 years ago
4 0

Answer:

Following are the program to the given question:

#include <iostream>//header file

#include <bits/stdc++.h>//header file

using namespace std;

int main()//main method

{

   int x,i,sum=0;//defining integer variable

   double average, median;//defining double variable

   cout<<"How many students were surveyed? ";//print message

   cin>>x;//input value

   int *a = new int[x]; //dynamically created array

   for(i = 0;i<x;i++)//defining for loop to input value in array

   {

       cout<<"Enter the number of movies seen by student number "<<i+1<<": ";//print message  

       cin>>a[i];//input value

   }

   for (int i = 0; i < x; i++)//defining loop for add value

       sum += a[i];   //use sum to add array value

   average = (double)sum/x;//defining average variable to calculate average

   cout<<"Average is "<<average<<endl;//print average value with message

   sort(a, a+x); //use sort method to sort array to find the median

   if (x % 2 != 0)//use if to check the even value

      median = (double)a[x/2];//calculating the median value

   else//esle block

       median = (double)(a[(x-1)/2] + a[x/2])/2.0;//calculating median value

   cout<<"Median is "<<median<<endl;//print median value with message

   int m_count=1 ,mode= a[0], c_count = 0;//defining integer variable

   for( i=1;i<x;i++)//defining for loop arrenge value

   {

       if(a[i]==a[i-1])//use if to check array value

       {

           c_count++;//increment c_count variable value

       }

       else//else block

       {

           if(c_count>m_count)//use if to check c_count greater than m_count

           {

               m_count = c_count;//holding value in m_count

               mode = a[i-1];//holding mode value

           }

           c_count = 1;//holding value integer value in c_count

       }

   }

   cout<<"Mode is "<<mode;//print mode value with message

   return 0;

}

Output:

Please find the attachment file.

Explanation:

  • Including header file.
  • Defining the main method.
  • Declaring integer and double type variables.
  • Declaring integer array.
  • Use the loop to the input value.
  • After input, the value uses double variable "average, the median" that uses the for loop and conditional statement to check the value and hold in its variable.
  • In the next step, another integer variable "m_count, mode, and c_count" is defined that uses the loop and conditional statement to check the median and mode value and hold its value into their variable.

You might be interested in
Your school computer library has a network that connects computers and devices within a few small rooms. what type of network do
Pachacha [2.7K]
A routed and secured network which can send internet access to all computers 

3 0
3 years ago
What does the merge &amp; center button in the alignment group on the home tab do?
e-lub [12.9K]
A merge and center does this;
if you have created a table,it just centers a sentance
6 0
3 years ago
What feature new to Windows Server 2012 provides the ability to find identical sets of data on a SAN based storage array and red
igor_vitrenko [27]

Answer:

Data Deduplication

Explanation:

In computing, data deduplication is a technique for eliminating duplicate copies of repeating data. This is also called single-instance storage.

Only applicable to Windows Server 2012 and newer versions, Data deduplication techniques ensure that only one unique instance of data is retained on storage media, such as disk, flash or tape.

Cheers

7 0
3 years ago
Under extreme programming, ________ and ________ are intimately related parts of the same process
Inessa05 [86]
The answer to this question is: coding and testing
Extreme programming is a software development methodology that aim to improve software quality by measuring whether the technology can be used to fulfill customer's requirement.
To actually get somethings that is accepted by the customers, various coding and testing the software will be done constantly
8 0
4 years ago
Read 2 more answers
____ are the computers that store network software and shared or private user files.
kodGreya [7K]
Servers <span>are the computers that store network software and shared or private user files.</span>
3 0
4 years ago
Other questions:
  • What are the 4-bit patterns used to represent each of the characters in the string "1301"? Only represent the characters between
    14·1 answer
  • Plz help ASAP
    10·1 answer
  • Jim is in the market for a car that will last for the next 10 years and has saved up some money for the purpose of a car. What’s
    8·2 answers
  • Create a do-while loop that asks the user to enter two numbers. The numbers should be added and the sum displayed. The loop shou
    5·1 answer
  • Colin Mackay Inc., a software company with its head office in Amsterdam, has employees across three continents. Certain project
    11·1 answer
  • What are the two basic classes of active directory objects?
    14·1 answer
  • Greg wants to check the amount of requests his website receives. What test can he use?
    6·1 answer
  • Windows is a GUI Operating System, what is the other type?
    8·1 answer
  • A(n) ______is like an intranet except it shares its resources with users from a distant location. Select your answer, then click
    10·1 answer
  • // This pseudocode is intended to describe
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!