Related questions
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;
}
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps
- C++ you have to you use #include <random> also included a sample output has too match the layout Thank youarrow_forwardIn this project you will generate a poker hand containing five cards randomly selected from a deck of cards. The names of the cards are stored in a text string will be converted into an array. The array will be randomly sorted to "shuffle" the deck. Each time the user clicks a Deal button, the last five cards of the array will be removed, reducing the size of the deck size. When the size of the deck drops to zero, a new randomly sorted deck will be generated. A preview of the completed project with a randomly generated hand is shown in Figure 7-50.arrow_forwardA(n) ___ is used in an array to across each element? a. Index b. Subscript C. Both a and b d. None of the abovearrow_forward
- Using C# in Microsoft Visual Studio create an application that grades the written portion of the driver’s license exam. The exam has 20 multiple-choice questions. (The correct answers are provided in the screenshot.) the program should store these correct answers in an array. The program should read the student’s answers for each of the 20 questions from a text file and store the answers in another array. (Create your own text file to test the application.) After the student’s answers have been read from the file, the program should display a message indicating whether the student passed or failed the exam. (A student must correctly answer 15 of the 20 questions to pass the exam.) It should then display the total number of correctly answered questions, the total number of incorrectly answered questions, and a list showing the question numbers of the incorrectly answered questions.arrow_forwardSuppose a teacher has five students who have taken four tests. The teacher uses the following grading scales to assign a letter grade to a student, based on the average of his or her four test scores. Test Score Letter Grade 90-100 80-89 70-79 60-69 0-59 A B C D F Create an application that uses an array of strings to hold the five student names, an array of five strings to hold each student's letter grades, and five arrays of four single precision numbers to hold each student's set of test scores.arrow_forwardThe intNums array is declared as follows: Dim intNums() As Integer = {10, 5, 7, 2}. Which of the following blocks of code correctly calculates the average value stored in the array? The intTotal, intSub, and dblAvg variables contain the number 0 before the loop is processed. a. Do While intSub < 4 intNums(intSub) = intTotal + intTotal intSub += 1 Loop dblAvg = intTotal / intSub b. Do While intSub < 4 intTotal += intNums(intSub) intSub = intSub + 1 Loop dblAvg = intTotal / intSub c. Do While intSub < 4 intTotal += intNums(intSub) intSub += 1 Loop dblAvg = intTotal / intSub – 1 d. Do While intSub < 4 intTotal = intTotal + intNums(intSub) intSub = intSub + 1 Loop dblAvg = intTotal / (intSub – 1)arrow_forward
- Text book imageDatabase System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationText book imageStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONText book imageDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- Text book imageC How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONText book imageDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningText book imageProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education