Question: Need corrections to the following C++ code so that it adheres to the requirements attached: #include #include #include class VectorOperations { private: std::vector numbers; public:

 Need corrections to the following C++ code so that it adheres

Need corrections to the following C++ code so that it adheres to the requirements attached:

#include

#include

#include

class VectorOperations {

private:

std::vector numbers;

public:

void getInput() {

for (int i = 0; i

int num;

cin>>num; numbers.push_back(num);

}

}

void displaySortedElements() {

std::sort(numbers.begin(), numbers.end());

std::cout

for (int i = 0; i

std::cout

}

std::cout

}

void displaySmallestElement() {

int smallest = numbers[0];

for (int i = 1; i

if (numbers[i]

smallest = numbers[i];

}

}

std::cout

}

void displayLargestElement() {

int largest = numbers[0];

for (int i = 1; i

if (numbers[i] > largest) {

largest = numbers[i];

}

}

std::cout

}

void displayTotal() {

int total = 0;

for (int i = 0; i

total += numbers[i];

}

std::cout

}

void displayAverage() {

int total = 0;

for (int i = 0; i

total += numbers[i];

}

double average = (double) total / 5;

std::cout

}

};

int main() {

VectorOperations obj;

obj.getInput();

obj.displaySortedElements();

obj.displaySmallestElement();

obj.displayLargestElement();

obj.displayTotal();

obj.displayAverage();

return 0;

}

- Prompt the user for 5 integer values - Stores the elements in a vector - Displays the sorted elements - Displays the smallest element - Displays the largest element - Displays the total of all elements - Displays the average of all the elements

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!