Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using C++ Vector class . #include using namespace std; #include #include /*function prototypes*/ void showMenu(); void add(vectorchar> &ch); void remove(vectorchar> &ch); void show(vectorchar> &ch); int

Using C++ Vector class

.image text in transcribed

#include

using namespace std;

#include

#include

/*function prototypes*/

void showMenu();

void add(vectorchar> &ch);

void remove(vectorchar> &ch);

void show(vectorchar> &ch);

int main(){

vectorchar> 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(vectorchar> &ch) {

/*prompt the user to enter a character

and add the character to the vector.*/

}

void remove(vectorchar> &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(vectorchar> &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(vector &ch) Prompts the user to provide a character and add that character into the vector 2. Remove(vector &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(vector &num) Show the existing members of the vector (order does not matter) . It will generate a message if it is empty Sample output: 1. Add a character 2. Remove a character. 3. Show the characters . Quit. Please enter a choice: 1 Please enter the character: a 1. Add a character 2. Remove a character. 3. Show the characters . Quit. Please enter a choice: 2 Please enter the character: c The character was not found 1. Add a character. 2. Remove a character. 3. Show the characters. 4. Quit Please enter a choice: 3 1. Add a character 2. Remove a character 3. Show the characters 4. Quit. Please enter a choice: 1 Please enter the character: b 1. Add a character. 2. Remove a character 3. Show the characters. 4. Quit. Please enter a choice: 2 Please enter the character: a The 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_2

Step: 3

blur-text-image_3

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

Question

LO22.5 List the main elements of existing federal farm policy.

Answered: 1 week ago