Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++ Change the attached code to display a menu: Enter one of the following F find a value R randomly shuffle the vector S

In C++

Change the attached code to display a menu: Enter one of the following F find a value R randomly shuffle the vector S sort the vector Q quit

If the user chooses F, confirm if the value is in the vector or not If the user chooses R, shuffle the vector and then display it. If the user chooses S, sort the vector and then display it. Put the above menu into a while loop which runs until the user enters Q or q to quit.You can handle the actions using an if else construct or a switch statement (the latter is preferred

#include  #include  #include  using namespace std; void displayVector(vector myStringVector); int main() { vector studentVector; vector::iterator myStringIterator; string proceed = "n"; string studentName; do { cout << "Enter student name: "; getline(cin, studentName); studentVector.push_back(studentName); cout << "Enter another student (Y/N): "; getline(cin, proceed); cout << endl; } while (proceed == "Y" || proceed == "y"); int studentNameIndex; //print the vector using iterators before removing the element displayVector(studentVector); //code to remove cout << "Enter the number to remove: "; cin >> studentNameIndex; cin.ignore(); studentVector.erase(studentVector.begin() + studentNameIndex - 1); //display the vector after removing the element displayVector(studentVector); //YOUR CODE BEGINS HERE system("pause"); return 0; } inline void displayVector(vector _myStringVector) { int i = 1; vector::const_iterator _myStringIterator; for (_myStringIterator = _myStringVector.begin(); _myStringIterator != _myStringVector.end(); _myStringIterator++) { cout << i << ": " << *_myStringIterator << endl; i++; } }

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

User Defined Tensor Data Analysis

Authors: Bin Dong ,Kesheng Wu ,Suren Byna

1st Edition

3030707490, 978-3030707491

More Books

Students also viewed these Databases questions

Question

107 MA ammeter 56 resistor ? V voltmeter

Answered: 1 week ago

Question

Generally If Drug A is an inducer of Drug B , Drug B levels will

Answered: 1 week ago

Question

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

Answered: 1 week ago