Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #include #include #include // to use sort() using namespace std; const int NUM_VALUES = 5; // Input NUM_VALUES of TheType into the vector parameter

image text in transcribed

#include

#include

#include

#include // to use sort()

using namespace std;

const int NUM_VALUES = 5;

// Input NUM_VALUES of TheType into the vector parameter

templatetypename TheType> void Read(vector& list) {

for (int j = 0; j

cin >> list.at(j);

}

}

// Output the elements of the vector parameter

templatetypename TheType> void Write(vector& list) {

long unsigned int j;

for (j = 0; j

cout

}

}

// Return the min, median, and max of the vector parameter in a new vector

templatetypename TheType> vector GetStatistics(vector& list) {

/* Type your code here. */

}

// Read values into a vector, sort the vector, output the sorted vector,

// then output the min, median, and max of the sorted vector

templatetypename TheType> void Run(vector& list) {

/* Type your code here. */

}

int main() {

vectorint> integers(NUM_VALUES);

Run(integers);

cout

vectordouble> doubles(NUM_VALUES);

Run(doubles);

cout

vector strings(NUM_VALUES);

Run(strings);

return 0;

}

please complete this code above in C++

Given the definitions of main(), Read() and Write(), complete main.cpp by implementing the following member functions: template vector GetStatistics(vector\& list) - Take a vector template as a parameter - Store the minimum, median, and maximum values of the vector parameter into a new vector - Return the new vector template void Run(vector\& list) - Take a vector template as a parameter - Call Read() with the vector parameter as an argument. Read() stores 5 input values into the vector parameter - Sort the vector parameter - Call Write0 to output the sorted vector - Output a new line - Call GetStatistics0 with the sorted vector as an argument. GetStatistics() returns a vector containing the minimum, median, and the maximum values of the sorted vector - Call Write0 to output the vector returned by GetStatistics( - Output a new line Note: vector.size() returns a long unsigned int, not an int. Hint: Use the built-in sort function to sort a vector. Ex: If the input is: 1.2.2onetwothreefourfive33.351.194.45.57 the output is

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

1. What is called precipitation?

Answered: 1 week ago

Question

1.what is dew ?

Answered: 1 week ago

Question

1.The difference between climate and weather?

Answered: 1 week ago

Question

1. What is Fog ?

Answered: 1 week ago

Question

How water vapour forms ?

Answered: 1 week ago

Question

c. What were you expected to do when you grew up?

Answered: 1 week ago