Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

code: Pageof 2 ZOOM #include using namespace std; #include #include /*function prototypes*/ void showMenu(); void add(vector &ch); void remove(vector &ch); void show(vector &ch); int main(){

image text in transcribed

code:

Pageof 2

ZOOM

#include

using namespace std;

#include

#include

/*function prototypes*/

void showMenu();

void add(vector &ch);

void remove(vector &ch);

void show(vector &ch);

int main(){

vector char_vec;

int input;

while (true) {

showMenu();

cin >> input;

switch (input){

case 1: add(char_vec);

break;

case 2: remove(char_vec);

break;

case 3: show(char_vec);

break;

case 4: return 0;

break;

default: cout

}

cout

}

return 0;

}

void showMenu() {

cout

cout

cout

cout

cout

}

/*complete the following functions: */

void add(vector &ch) {

/*prompt the user to enter a character

and add the character to the vector.*/

}

void remove(vector &ch) {

/*prompt the user to enter a character

to remove. then remove that character

from the vector.*/

/*HINT: you need to use the iterator

vector::iterator i to iterate through

your vector using a for loop. if the item

in your vector at that index is equal to the

key, then erase the item and print a message

stating that the item has been removed.*/

}

void show(vector &ch) {

/*print the contents of the vector.

remember to check if the vector is

empty first.*/

/*HINT: you need to use the iterator

vector::iterator i to loop

through your vector and print its

contents*/

}

Design the following menu-driven application using C++ Vector class. Implement the following five functions 1. Add(vectorcchar> &ch) Prompts th ser to provide a character and add that character int the vect r 2. Remove(vectorcchar> &ch) Prompts the user to provide a character. If the character is found in the vector, it removes that character. Otherwise, it generates a message 3. Show(vectorcint &num) sh w the existing members f the vector ( rder d matter) It wi11 generate a message if it is empty n t Sample output: Add a character Renove a character Show the characters Quit dd a character Remove a character Show the characters Quit Lease enter a choice: 2 Lease enter the character: he character was not found Add a character Remove a character Sho the characters Quit Lease enter a choice: 1 Lease enter the character: a Please enter a choice:3 Add a character Renove a character Show the characters Quit Add a character Remove a character Show the characters Quit Lease enter a choice: 1 Lease enter the character: b Lease enter a choice: 2 Lease enter the character: a he character has been removed

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

Understanding Oracle APEX 5 Application Development

Authors: Edward Sciore

2nd Edition

1484209893, 9781484209899

More Books

Students also viewed these Databases questions