Question
import java.util.LinkedList; import java.util.Queue; public class Lab_Assignment { public static void main(String[] args) { // TODO Auto-generated method stub String[] words = { Cat, Dog,
import java.util.LinkedList; import java.util.Queue;
public class Lab_Assignment {
public static void main(String[] args) { // TODO Auto-generated method stub
String[] words = { "Cat", "Dog", "Antelope", "Walrus", "Cat", "Ant", "Carrot", "Mouse", "Rat", "Tiger", "Dog", "Horse", "Worm", "Frog", "Elephant", "Goat", "Mule", "Cat", "Reindeer", "Whale", "Baboon", "Inchworm", "Dog", "Starfish" };
Queue
Queue
String findString = "Cat"; int nextPosition = findNext(q, findString, 1);
if (nextPosition == -1) { System.out.println("The string is not found!"); } else System.out.println("The position of " + findString + " is: " + nextPosition);
System.out.println("Showing the queue as a string: "+toString(q));
String findOccurance = "Dog"; int occur_times = countOccurrences(q, findOccurance); System.out.println("'" + findOccurance + "'" + " is present " + occur_times + " times in the list."); Queue
private static Queue
private static int countOccurrences(Queue
private static Queue
private static String toString(Queue
private static int findNext(Queue
}
You are given a Java file, which you would need to complete by implementing the methods mentioned there.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started