The user then gets to choose options from the following menu: 1. Remove adjacent duplicate characters appearing in the input string, and report the number of characters removed Create a new linked list comprising of only the vowels used in the input string and in the exact order. Display the contents of this 2. linked list 3. Delete all occurrences of a character: Please enter the character 4. Search for a substring in the input string: Please enter the substring 5. Display the linked list in reverse 6. Count of occurrences of a character: Please enter a character 7. Display the current content of the linked list 8. Exit Here are some further clarifications on some of the menu options: Option 1. For example we would like to change aarppexxx to become arpex. Option 2. For example beautiful should give us a new linked list containing eauiu. Option 4. Searching for the substring iss in mississippi must display the following message: The substring iss is found 2 time (s) in the input string. Option 7. This option will display the current content of the linked list reflecting possible changes as a result of menu options chosen by the user.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

in option 4 i want it to tell also which string is coming double it should show it
Option 4. Searching for the substring iss in mississippi must display the following
message:
The substring iss is found 2 time(s) in the input string.
Option 7. This option will display the current content of the linked list reflecting possible
changes as a result of menu options chosen by the user.

you can see picture for help
package javaapplication2;

import java.util.*;

public class WordOp

{

public static void main(String args[])

{

Scanner sc = new Scanner(System.in);

System.out.print("Enter the word in lowercase letters :");

String word = sc.nextLine();

char c ;

String temp;

int count;

LinkedList<Character> linkedlist= new LinkedList<>();

while(true)

{

//ask the user for the choice of operation

System.out.print("\n*******Word Operations******\n1.Remove adjacent dupicate character\n2.create LinkedList Vowels\n3.delete occurence of character\n4.search substring\n5.Display the linked list in revers\n6.count occurrence of the character\n7.Diplays the content of the linked list\n8.Exit\n.Enter your choice:");

int choice = sc.nextInt();

// use a switch to execute statement of the respective choice

switch(choice)

{

case 1 : c= word.charAt(0);

temp = c+"";

// variable to maintain the count of removed characters

count = 0 ;

for (int i=1 ; i<word.length() ; i++)

{

// if the current character is not same as previous then add it to temp

if(word.charAt(i)!=c)

{

temp=temp+word.charAt(i);

c=word.charAt(i);

}

else

count++;

}

word = temp;

System.out.println("Word: "+ word);

System.out.println("Number of characters removed: "+count);

break ;

case 2 : linkedlist = new LinkedList<>();

String Vowels="aeiou";

for(int i=0 ; i<word.length(); i++)

{

// check if the character is contained in the vowels string

if(Vowels.contains(word.charAt(i)+""))

linkedlist.add(word.charAt(i));

}

System.out.print("Elements of linkedlist:");

for(char ch: linkedlist)

System.out.print(ch);

System.out.println();

break;

case 3 : System.out.print("Enter the character:");

c=sc.next().charAt(0);

temp="";

for(int i=0 ; i<word.length(); i++)

{

// if the character in not specified character then it add to temp

if(word.charAt(i)!=c)

temp=temp+word.charAt(i);

}

word=temp;

System.out.println("Word: "+word);

break;

case 4 : System.out.print("Enter the substring;" );

// after entering the choice, we press enter button which will generate \n character.

//this will be scanned by nextline() method which will give us a blank input hence

//we need to absorb this \n character with the below line

sc.nextLine();

//after that we will scan the nextLine

temp= sc.nextLine();

// use contains() method of string class to check if the substring is present in the word

//it will return true if the specified string is present in the word

if (word.contains(temp))

System.out.println("the substring is present");

else

System.out.println("The substring is not present");

break;

case 5 : // use temp to generate the linkedlist in reverse order

temp="";

System.out.print("Elements of linked list in reverse:");

//loop through each character present in the linkedlist

for(char ch: linkedlist)

temp=ch+temp; //contact the character in front of the temp string each time

System.out.println(temp);

break;

case 6 : System.out.print("Enter the character:");

c=sc.next().charAt(0);

count=0;

//use a for loop and increment count if the current character is specified character

for(int i=0; i<word.length(); i++)

count++;

System.out.println("occurrence:+"+count);

break;

case 7 : System.out.print("Elements of linkedlist:");

for (char ch:linkedlist)

System.out.print(ch);

System.out.println();

break;

case 8 : // use exit () to close the program

System.exit(0);

default : System.out.println("Enter a valid choice");

}

}

}

}

The user then gets to choose options from the following menu:
1.
Remove adjacent duplicate characters appearing in the input string,
and report the number of characters removed
Create a new linked list comprising of only the vowels used in the
input string and in the exact order. Display the contents of this
2.
linked list
3.
Delete all occurrences of a character: Please enter the character
4.
Search for a substring in the input string: Please enter the substring
5.
Display the linked list in reverse
6.
Count of occurrences of a character: Please enter a character
7.
Display the current content of the linked list
8.
Exit
Here are some further clarifications on some of the menu options:
Option 1.
For example we would like to change aarppexxx to become arpex.
Option 2.
For example beautiful should give us a new linked list containing eauiu.
Option 4.
Searching for the substring iss in mississippi must display the following
message:
The substring iss is found 2 time (s) in the input string.
Option 7.
This option will display the current content of the linked list reflecting possible
changes as a result of menu options chosen by the user.
Transcribed Image Text:The user then gets to choose options from the following menu: 1. Remove adjacent duplicate characters appearing in the input string, and report the number of characters removed Create a new linked list comprising of only the vowels used in the input string and in the exact order. Display the contents of this 2. linked list 3. Delete all occurrences of a character: Please enter the character 4. Search for a substring in the input string: Please enter the substring 5. Display the linked list in reverse 6. Count of occurrences of a character: Please enter a character 7. Display the current content of the linked list 8. Exit Here are some further clarifications on some of the menu options: Option 1. For example we would like to change aarppexxx to become arpex. Option 2. For example beautiful should give us a new linked list containing eauiu. Option 4. Searching for the substring iss in mississippi must display the following message: The substring iss is found 2 time (s) in the input string. Option 7. This option will display the current content of the linked list reflecting possible changes as a result of menu options chosen by the user.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY