
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);
}
}

Trending nowThis is a popular solution!
Step by stepSolved in 2 steps

- I am new to Haskell and I need someone to explain the syntax of this function. The function is supposed to take a single integer parameter. It indicates the maximum value of Fibonacci numbers that will be in the list and it uses recursion to generate the list. fibList n = go n 1 1 where go n f s | (f+s) > n = [] | otherwise = (f+s) : go n s (f+s)arrow_forwardThe for construction is a loops that iteratively processes a given list. Consequently, it works so long even though there are objects to process. What about this claim: true or false?arrow_forwardWrite a program that animates the linear search algorithm. Create a list that consists of 20 distinct numbers from 1 to 20 in a random order. The elements are displayed in a histogram, as shown in Figure 10.17. You need to enter a search key in the text field. Clicking the Step button causes the program to perform one comparison in the algorithm and repaints the histogram with a bar indicating the search position. When the algorithm is finished, display a dialog box to inform the user. Clicking the Reset button creates a new random list for a new start.arrow_forward
- implement C# code to create a list of Card objects, add two Card objects to the list, use a loop to flip the cards in the list and print it.arrow_forwardpython LAB: Subtracting list elements from max When analyzing data sets, such as data for human heights or for human weights, a common step is to adjust the data. This can be done by normalizing to values between 0 and 1, or throwing away outliers. Write a program that adjusts a list of values by subtracting each value from the maximum value in the list. The input begins with an integer indicating the number of integers that follow.arrow_forwardGiven a string with duplicate characters in it. Write a program to generate a list that only contains the duplicate characters. In other words, your new list should contain the characters which appear more than once. Suggested Approach Used two nested for loops. The first for loop iterates from 0 to range(len(input_str)). The second for loop iterates from first_loop_index + 1 to range(len(input_str)). The reason you want to start at first_loop_index + 1 in the nested inner loop is that the outer loop already checks the current character. In the nested inner loop, you want to check the remaining characters in the input string. If the current character of the outer loop matches the character of the nested loop AND the character is not already IN the duplicate list, append it to the list nhantran Sample Output 1 List of duplicate chars: ['n', 'a'] Sample Input 2 pneumonoultramicroscopicsilicovolcanoconiosis Sample Output 2 List of duplicate chars: ['p', 'n', 'u', 'm', 'o', 'l', 'r', 'a',…arrow_forward
- Write a program in c++ and make sure it works, that reads a list of students (first names only) from a file. It is possible for the names to be in unsorted order in the file but they have to be placed in sorted order within the linked list.The program should use a doubly linked list.Each node in the doubly linked list should have the student’s name, a pointer to the next student, and a pointer to the previous student. Here is a sample visual. The head points to the beginning of the list. The tail points to the end of the list. When inserting consider all the following conditions:if(!head){ //no other nodes}else if (strcmp(data, head->name)<0){ //smaller than head}else if (strcmp(data, tail->name)>0){ //larger than tail}else{ //somewhere in the middle} When deleting a student consider all the following conditions:student may be at the head, the tail or in the middleBelow, you will find a sample of what the file looks like. Notice the names are in…arrow_forwardJava Programming language Please help me with this. Thanks in advance.arrow_forwardfor some reason in the list object when i try to insert the code into a linked list it inserts the characters backwards instead of forwards. I have to input characters from a user created string individually into a linked list. the linked list cannot change because the teacher requires me to use the specified code in my textbook. i would appreciate if you would explain the problem and solution in words and not code. the code is in Java is there a way to get this program to output correctly? OUTPUT please enter a string.coppermakerimprintList (first -->last): tnirpmirekamreppoc 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 ownpublic static void main(String[] args){Scanner input = new Scanner(System.in);linkedList list = new linkedList();char character;System.out.println("please enter a string.");String…arrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY





