Using C++ Language Modify the provided code as follows. • Declare another array of the same size and type and call it above_average. • Calculate the average height of the 12 students. • In a loop of your choice, check if the height of an individual student is larger than the average. If it is larger than the average, copy this element to the above _average array. Note that the above_average array will most likely have a smaller number of elements than the original height array. This also means that the locations of a specific student’s height in the two arrays may not be the same after copying. So, you will need a separate counter to keep track of elements in the new array. • Display the content of the new array as well as the average with suitable prompt.    code so far:  #include using namespace std; int main() {     const int SIZE=12;     int sumHeight=0;     int height[SIZE];     int above_average[SIZE];     double average;          for(int i=0;i>height[i];         sumHeight+=height[i];     }          average = sumHeight/12;     //in a loop, check if height is above average     //copy to above_average array if it is               cout<<"You entered: "<

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter8: Arrays
Section: Chapter Questions
Problem 9PE
icon
Related questions
Question

Using C++ Language

Modify the provided code as follows.
• Declare another array of the same size and type and call it above_average.
• Calculate the average height of the 12 students.
• In a loop of your choice, check if the height of an individual student is larger
than the average. If it is larger than the average, copy this element to the
above _average array.
Note that the above_average array will most likely have a smaller number of
elements than the original height array. This also means that the locations of
a specific student’s height in the two arrays may not be the same after copying.
So, you will need a separate counter to keep track of elements in the new array.
• Display the content of the new array as well as the average with suitable
prompt. 

 

code so far: 

#include <iostream>
using namespace std;

int main()
{
    const int SIZE=12;
    int sumHeight=0;
    int height[SIZE];
    int above_average[SIZE];
    double average;
    
    for(int i=0;i<SIZE;++i)
    {
        cout<<"Enter height in inches of student #"<<i+1<<": ";
        cin>>height[i];
        sumHeight+=height[i];
    }
    
    average = sumHeight/12;
    //in a loop, check if height is above average
    //copy to above_average array if it is
    
    
    cout<<"You entered: "<<endl;
    for(int i=0;i<SIZE;++i)
    {
        cout<<height[i]<<", ";
    }
    cout<<endl;
    
    
    cout<<"Average is: "<<average<<endl;
    for (//enter "above average" code here
    {
        cout<<"Above average: "<<above_average<<endl;
    }
    return 0;
}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Program on Numbers
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning