PANEL þublic class Finding { ! // Find all unique words in a sentence that contain a sub string. // a sentence is a comb

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899604
Joined: Mon Aug 02, 2021 8:13 am

PANEL þublic class Finding { ! // Find all unique words in a sentence that contain a sub string. // a sentence is a comb

Post by answerhappygod »

Panel Thublic Class Finding Find All Unique Words In A Sentence That Contain A Sub String A Sentence Is A Comb 1
Panel Thublic Class Finding Find All Unique Words In A Sentence That Contain A Sub String A Sentence Is A Comb 1 (78.03 KiB) Viewed 23 times
PANEL þublic class Finding { ! // Find all unique words in a sentence that contain a sub string. // a sentence is a combination of words with a space in between. // For example: "I love doing programming" is a sentence with a combination of "I", "love", "doing", "programming" words. private String sentence; // TODO: Create 2 constructors: 1 empty and 1 with sentence input // TODO: Create setters and getters public String[] findAllWords ContainSubstring(String substr){ String[] ret = new String[sentence.split( regex: " ").length]; // Create empty return array with the length of number of words in the sentence // Given a substr which is a combination of characters, we want to find all of the words that contain the substr in the sentence. // If substr is "" or null, you should return every words in the sentence. // Example, if the substr is "ing" and the sentence is "I love doing programming" then the return should contains "doing" and "programming" words since both of the words contain "ing". // Another example, if substr is "ing" and the sentence is "I love doing programming and doing cooking", then the return should contain "doing", "programming", and "cooking". One "doing" is removed because it's a // TODO: YOUR CODE HERE return ret; } public boolean checkExist(String[] array, String word){ // Given an array of words, check if a given word appears in the array. // This method should be triggered by findAllWords ContainSubstring method // TODO: YOUR CODE HERE return false; // Return false for compilation, remove when done } public static void printoutput(String[] ret){ String printval = ""; for (String s: ret){ if (s != null) { printval += 5 + " "; } } System.out.println(printval); } Run Debug public static void main(String[] args) { 1 ton. Croato findinot obiect with contance value of "I love doing nonammino" In 1, Col1 Spaces: 2 UTF-8 LF {} Java R 0
46 Run Debug public static void main(String[] args) { // TODO: Create findingi object with sentence value of "I love doing programming" -- // TODO: Using finding1 to call findAllwords ContainSubString with input of "ing" and assign the return value to reti variable // TODO: call printoutput method (this has already been written for you, with reti parameter input // This should print out "doing programming" // TODO: Using finding1 to call findAllWords ContainSubstring with input of "0" and assign the return value to ret2 variable // TODO: call printoutput method with ret2 parameter input // This should print out "love doing programming" 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 // TODO: Using finding' to call findAllWords ContainSubstring with input ofmmand assign the return value to ret3 variable // TODO: call printoutput method with reti parameter input // This should print out "I love doing programming" TODO: Use findingi setter method to set sentence to new value of "I love doing programming and doing cooking." // TODO: Using findingi to call findAllWordsContainSubString with input of "ing" and assign the return value to ret4 variable // TODO: call printoutput method with ret4 parameter input // This should print out "doing programming cooking" } } 14 In 1 Col 1 Spaces: 2 UTF-8 IF {} laya A
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply