in this assignment i have to remove vowels from a string using a linked list. the linked list and link code is from a textbook and cannot be changed if the code alters the data structure. for some reason when i implement this code it gives me a logical error where the program only removes all instances of the first vowel in a string instead of moving through all vowels of the string and removing each one with all instances. i would appreciate if you could tell me the problem and solution in words and not in code. The code is in java. output

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 this assignment i have to remove vowels from a string using a linked list. the linked list and link code is from a textbook and cannot be changed if the code alters the data structure. for some reason when i implement this code it gives me a logical error where the program only removes all instances of the first vowel in a string instead of moving through all vowels of the string and removing each one with all instances. i would appreciate if you could tell me the problem and solution in words and not in code. The code is in java.

output

please enter a string.
research
h
c
r
a
e
s
e
r
false
List (first -->last): research
List (first -->last): research
List (first -->last): rsarch

CODE 

MAIN FUNCTION

import java.util.Scanner;
/**
* Write a description of class test here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class test
{
// instance variables - replace the example below with your own
public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
linkedList list = new linkedList();
char character;
char keyChar;

System.out.println("please enter a string.");

String inString = input.nextLine();

for(int i = inString.length() - 1; i >= 0; i--)
{
character = inString.charAt(i);
System.out.println(character);
list.insertFirst(character);
}

System.out.println(list.isEmpty());
list.displayList();



list.displayList();
for(int i = 0; i < inString.length(); i++)
{
if(inString.charAt(i) == 'a'|| inString.charAt(i) == 'e'||inString.charAt(i) == 'i'||inString.charAt(i) == 'o'||inString.charAt(i) == 'u')
{
keyChar = inString.charAt(i);
for(int j = 0; i < inString.length(); i++)
{
if(!(list.isEmpty()))
{
list.delete(keyChar);
}
}
}
}
list.displayList();
}
}

LINKED LIST OBJECT

public class linkedList
{
private link first;
public linkedList()
{
first = null;
}

public boolean isEmpty()
{
return (first==null);
}

public void insertFirst(char id)
{
link newLink = new link(id);
newLink.next = first;
first = newLink;
}

public link delete(char key)
{
link current = first;
link previous = first;

while(current.dData != key)
{
if(current.next == null)
{
return null;
}
else
{
previous = current;
current = current.next;
}
}
if( current == first)
{
first = first.next;
}
else
{
previous.next = current.next;
}
return current;
}

public void displayList()
{
System.out.print("List (first -->last): ");
link current = first;
while(current != null)
{
current.displayLink();
current = current.next;
}
System.out.println("");
}

public link find(char key)
{
link current = first;
while(current.dData != key)
{
if(current.next == null)
{
return null;
}
else
{
current = current.next;
}
}
return current;
}
}

LINK OBJECT

public class link
{
public char dData;
public link next;
public link prev;

public link(char dd)
{
dData = dd;

}

public void displayLink()
{
System.out.print(dData);
}
}

 

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