An incomplete program named w pl java, which must include three methods, is provided. You must implement two methods within the program as described below. The third method, which is a main method, is already written in the program and you can use it to test your program. The two methods you mat inplement are: • find method • Signature: public static vold find(int[] . int x) • Behavior: • Reccives an array of integers a and an integer x • Performs a lincar search on a for x. • If x is in a, print the indexes of the aray slots where x is stored (there may be multiple x's in a) on the screen. • Ifx is not in a, print the message "x does not exist" on the screen. Note that you should not use Java's built-in method. Your program must scan and search the armay. • isPrifie method • Signature: public static boolean isprefix(String s1, String s2) • Behavior: • Receives two strings sl and s2. Assume that length of sl length of s2. • Returns true if sl is a prefix of s2 and returns false otherwise. Note that you should not use Java's built-in method. Your program must determine whether al is a prefix of s2 by comparing characters, one at a time, in the two strings. • Main method The main method is already written in the given file and it is used to test above two methods. Afier completing the above two methods, if you run your peogram, your output mast be: S is in a(0) S is in a(2] 5 is in a(7) se does not exist abc is a prefix of abcde abc is not a prefix of abdef

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
An incomplete program named w_pl java, which must include three methods, is provided.
You must implement two methods within the program as described below. The third method,
which is a main method, is already written in the program and you can use it to test your
program.
The two methods you mast inplement are:
• find method
• Signature:
public statie vold find(int[] a, int x)
• Behavior:
• Reccives an array of integers a and an integer x
• Performs a linear search on a for x.
• If x is in a, print the indexes of the aray slots where x is stored (there may be multiple
x's in a) on the screen.
• Ifx is not in a, print the message "x does not exist" on the screen.
Note that you should not use Java's built-in method. Your program must scan and search the
array.
• isPrifie method
• Signature:
public statie boolean isPrefix(String s1, String s2)
• Behavior:
• Receives two strings sl and s2. Assume that length of sl length of s2.
Returns true if sl is a prefix of s2 and returns false otherwise.
Note that you should not use Java's built-in method. Your program must determine whether
sl is a prefix of s2 by comparing characters, one at a time, in the two strings.
main method
The main method is already written in the given file and it is used to test above two methods.
After completing the above two methods, if you run your program, your output mast be:
5 is in a[0]
5 is in a[2]
5 is in a[7]
18 does not exist
abc is a prefix of abcde
abc is not a prefix of abdef
Transcribed Image Text:An incomplete program named w_pl java, which must include three methods, is provided. You must implement two methods within the program as described below. The third method, which is a main method, is already written in the program and you can use it to test your program. The two methods you mast inplement are: • find method • Signature: public statie vold find(int[] a, int x) • Behavior: • Reccives an array of integers a and an integer x • Performs a linear search on a for x. • If x is in a, print the indexes of the aray slots where x is stored (there may be multiple x's in a) on the screen. • Ifx is not in a, print the message "x does not exist" on the screen. Note that you should not use Java's built-in method. Your program must scan and search the array. • isPrifie method • Signature: public statie boolean isPrefix(String s1, String s2) • Behavior: • Receives two strings sl and s2. Assume that length of sl length of s2. Returns true if sl is a prefix of s2 and returns false otherwise. Note that you should not use Java's built-in method. Your program must determine whether sl is a prefix of s2 by comparing characters, one at a time, in the two strings. main method The main method is already written in the given file and it is used to test above two methods. After completing the above two methods, if you run your program, your output mast be: 5 is in a[0] 5 is in a[2] 5 is in a[7] 18 does not exist abc is a prefix of abcde abc is not a prefix of abdef
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 3 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education