Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is runner code: import java.util.Scanner; import java.util.ArrayList; public class runner_U7_L4_Activity_Two{ public static void main(String[] args){ Scanner scan = new Scanner(System.in); ArrayList words = new

image text in transcribed

This is runner code: import java.util.Scanner; import java.util.ArrayList;

public class runner_U7_L4_Activity_Two{

public static void main(String[] args){ Scanner scan = new Scanner(System.in); ArrayList words = new ArrayList(); System.out.println("Please enter words, enter STOP to stop the loop."); String input = scan.nextLine(); while(!input.equals("STOP")){ words.add(input); input = scan.nextLine(); } System.out.println("Enter String to search for."); input = new String(scan.nextLine()); System.out.println("searchLast returns: " + U7_L4_Activity_Two.searchLast(words, input)); }

}

Instructions Write a public static method named searchtast which implements a modified version of the linear search algorithm on an ArrayList of string objects. Instead of returning the index of the first appearance of the target String in the ArrayList your method should return the index of the last appearance of this String. If the target String is not in the ArrayList your method should return -1. Write your searchlast method in the U7_14_Activity_Two class, and ensure that the parameters for the method are an ArrayList of String objects followed by a String. Use the runner class to test your method but do not add a main method to your U7_L4_Activity_Two.java file or your code will not be scored correctly

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Principles Of Multimedia Database Systems

Authors: V.S. Subrahmanian

1st Edition

1558604669, 978-1558604667

More Books

Students also viewed these Databases questions

Question

Discuss why human resources managers need to understand strategy.

Answered: 1 week ago

Question

How are members held accountable for serving in the assigned roles?

Answered: 1 week ago