Write a menu-driven program that allows a user to do the following tasks with a
ID: 3536130 • Letter: W
Question
Write a menu-driven program that allows a user to do the
following tasks with a list of words:
Requirenments
Your program must implement and use the following
methods:
String word)
This method adds the word parameter to the words
array only if words does not already contain it. It
returns true if word was added to words;
false otherwise.
numWords, String word)
This method removes the word parameter from the
words array only if words contains it. It returns
true if word was found and removed from
words; false otherwise.
numWords)
This method prints the elements in the words parameter to
the screen, in some reasonable format.
String word)
This method searches for the word parameter in the
words array. If found, it returns the index of
word; otherwise it returns -1.
This method prints the menu options to the screen, reads in the
user's selection, and validates it. It returns the valid option
selection.
Tips and Hints
first call the findWord method to determine if the array
contains the specified word.
array, all elements to the right of the found word in the array
will need to be shifted to the left one index.
Sample run(s):
Welcome to WordList!
--------------------
1. Add Word
2. Remove Word
3. Print Words
4. Quit
Choose an option(1-4): 1
Enter a word to add to the wordList: terrific
terrific has been added.
1. Add Word
2. Remove Word
3. Print Words
4. Quit
Choose an option(1-4): 1
Enter a word to add to the wordList: not
not has been added.
1. Add Word
2. Remove Word
3. Print Words
4. Quit
Choose an option(1-4): 1
Enter a word to add to the wordList: assignment11
assignment11 has been added.
1. Add Word
2. Remove Word
3. Print Words
4. Quit
Choose an option(1-4): 1
Enter a word to add to the wordList: is
is has been added.
1. Add Word
2. Remove Word
3. Print Words
4. Quit
Choose an option(1-4): 1
Enter a word to add to the wordList: terrific
terrific is already present.
1. Add Word
2. Remove Word
3. Print Words
4. Quit
Choose an option(1-4): 2
Enter a word to remove from the wordList: not
not has been removed.
1. Add Word
2. Remove Word
3. Print Words
4. Quit
Choose an option(1-4): 2
Enter a word to remove from the wordList: terrible
terrible is not present.
1. Add Word
2. Remove Word
3. Print Words
4. Quit
Choose an option(1-4): 3
[terrific, assignment11, is]
1. Add Word
2. Remove Word
3. Print Words
4. Quit
Choose an option(1-4): 4
Explanation / Answer
program with no error......plz rate me 5 and provide me points thnx.... :)
#include<iostream.h>
void main()
{
char word[100][100],temp[100];
int i,n;
cout<<"enter the number of word you want to enter in an array";
cin>>n;
for(i=0;i<n;i++)
{
cin>>word[i];
}
int ch=1;
while(ch!=4)
{
cout<<"Enter your choice 1.Add Word 2.Remove Word 3.Print Word 4.Quit ";
cin>>ch;
switch(ch)
{
case 1:
if(n!=100)
{
n++;
cout<<"enter word to add in an array ";
cin>>temp;
word[n][100]=temp[100];
cout<<"Word is added in a list";
}
else
{
cout<<"word list is full ";
}
break;
case 2:
if(n!=0)
{
cout<<"enter word to delete ";
cin>>temp;
for(i=0;i<n;i++)
{
if(word[i][100]==temp[100])
{
for(int j=i;j<n;j++)
{
word[j][100]=word[j+1][100];
}
cout<<"word is deleted from a list";
}
}
}
else
cout<<"list is already empty";
break;
case 3:
cout<<" word is a list is ";
for(i=0;i<n;i++)
cout<<word[i]<<",";
break;
case 4:
cout<<"Thank You for using this program ";
break;
default:
cout<<"enter correct option ";
break;
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.