![thutch1950oww9q0](/avatars/49287.jpg)
thutch1950oww9q0
05.06.2020 •
Computers and Technology
Assume that the classes listed in the Java Quick Reference have been imported where appropriate.
Unless otherwise noted in the question, assume that parameters in method calls are not null and that methods are called only when their preconditions are satisfied.
In writing solutions for each question, you may use any of the accessible methods that are listed in classes defined in that question. Writing significant amounts of code that can be replaced by a call to one of these methods will not receive full credit.
Some applications use a controlled vocabulary to describe, or tag, things. A controlled vocabulary is a limited set of keywords from which appropriate tags can be chosen.
The Vocab class, shown below, contains methods used to analyze words in terms of their presence in a controlled vocabulary. You will write two methods of the Vocab class.
public class Vocab
{
/** The controlled vocabulary for a Vocab object. */
private String[] theVocab = { /* contents not shown */ };
/** Searches for a string in theVocab. Returns true if its String parameter str
* is an exact match to an element in theVocab and returns false otherwise.
*/
public boolean findWord(String str)
{
/* implementation not shown */
}
/** Counts how many strings in wordArray are not found in theVocab, as described in
* part (a).
*/
public int countNotInVocab(String[] wordArray)
{
/* to be implemented in part (a) */
}
/** Returns an array containing strings from wordArray not found in theVocab,
* as described in part (b).
*/
public String[] notInVocab(String[] wordArray)
{
/* to be implemented in part (b) */
}
}
The countNotInVocab method returns an int that contains the number of words in its parameter wordArray that are not found in the instance variable theVocab.
A helper method, findWord, has been provided. The findWord method searches for an individual string in theVocab, returning true if an exact match between its String parameter and an element of theVocab is found, and returning false otherwise.
(a) Write the countNotInVocab method. Assume that there are no duplicates in wordArray. You must use findWord appropriately to receive full credit.
/** Counts how many strings in wordArray are not found in theVocab, as described in
* part (a).
*/
public int countNotInVocab(String[] wordArray)
The notInVocab method returns an array of String objects that contains only elements of its parameter wordArray that are not found in theVocab. The array that is returned by notInVocab should have exactly one element for each word in wordArray that is not found in theVocab. Assume that there are no duplicates in wordArray.
The following example illustrates the behavior of the notInVocab method.
theVocab:
"time""food""dogs""cats""health""plants""sports"
wordArray:
"dogs""toys""sun""plants""time"
Array returned by notInVocab:
"toys""sun"
(b) Write the notInVocab method. Assume that there are no duplicates in wordArray. You must call findWord and countNotInVocab appropriately in order to receive full credit.
/** Returns an array containing strings from wordArray not found in theVocab,
* as described in part (b).
*/
public String[] notInVocab(String[] wordArray)
Solved
Show answers
More tips
- A Animals and plants Want a Perfect Lawn? Learn How to Plant Grass the Right Way...
- A Animals and plants How to Properly Care for a Pet Decorative Rabbit at Home?...
- C Computers and Internet How to Check the Speed of My Internet?...
- H Health and Medicine 10 Ways to Cleanse Your Colon and Improve Your Health...
- W Work and Career How to Write a Resume That Catches the Employer s Attention?...
- C Computers and Internet Е-head: How it Simplifies Life for Users?...
- F Family and Home How to Choose the Best Diapers for Your Baby?...
- F Family and Home Parquet or laminate, which is better?...
- L Leisure and Entertainment How to Properly Wind Fishing Line onto a Reel?...
- L Leisure and Entertainment How to Make a Paper Boat in Simple Steps...
Answers on questions: Computers and Technology
- C Computers and Technology Explain how to use hashing to check whether all elements of a list are distinct. What is the time efficiency of this application...
- C Computers and Technology 8. Write a query that will list the number of times each book has been checked out. List the book number, book title and number of times each book has been checked out...
- C Computers and Technology When two or more simple machines work together, they are called a(n) a. compound machine c. screw b. effort machine d. simple machine...
- C Computers and Technology Consider a computer system, where each processor can independently perform a separate task. given that the response time on a computer system for a single task is 8 seconds,...
- C Computers and Technology My coding will not work. I don t know what the issue....
- M Mathematics Why did the noob give 100 free points?...
- M Mathematics Given f(x) = 3^root x+2 and g(x) = x^3, prove whether or not f(x) and g(x) are inverse functions....
- E English Select 10 words or phrases created by or attributed to William Shakespeare and use each one correctly in an original sentence....
- E English 3 examples of when people used body language in seedfolks...
- M Mathematics A store is going out of business, they are advertising that Everything is 40% Off! You have had your eye on a new pair of shoes that were originally $156. What is the sale...
Ответ:
rcre2nvijrnv
u1bcihdebc
nn
Ответ:
Explanation:
it is important to be succinct, and help the reader to find the information that they need quickly, and without wading through reams of superfluous information. formatting of table plays an important role in presenting the data clearly and scuccinctly.