subject

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""pl ants""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)

ansver
Answers: 1

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 08:30, marialuizavalen
Today is the anniversary of me being on yet, i don't need it anymore! here's a picture of my dog wearing a bowtie! my question is, how do i delete my account?
Answers: 1
image
Computers and Technology, 23.06.2019 01:40, littlebirdd987
You have a linux system that has a 1000gb hard disk drive, which has a 90gb partition containing an ext4 filesystem mounted to the / directory and a 4gb swap partition. currently, this linux system is only used by a few users for storing small files; however, the department manager wants to upgrade this system and use it to run a database application that will be used by 100 users. the database application and the associated data will take up over 200gb of hard disk space. in addition, these 100 users will store their personal files on the hard disk of the system. each user must have a maximum of 5gb of storage space. the department manager has made it very clear that this system must not exhibit any downtime as a result of hard disk errors. how much hard disk space will you require, and what partitions would you need to ensure that the system will perform as needed? where would these partitions be mounted? what quotas would you implement? what commands would you need to run and what entries to /etc/fstab would you need to create? justify your answers.
Answers: 3
image
Computers and Technology, 23.06.2019 06:00, Disd112984
Which statement is true of web-based social media? a. they allow consumers to interact with and update content. b. they cannot be updated easily, as compared to print media. c. they are expensive to produce and maintain, as compared to print and television. d. they can exist independent of the internet.
Answers: 1
image
Computers and Technology, 24.06.2019 02:20, Jonny13Diaz
The first time a user launches the powerpoint program, which view is shown allowing the user to access recent presentations or create new presentations based on templates?
Answers: 1
You know the right answer?
Assume that the classes listed in the Java Quick Reference have been imported where appropriate. Un...

Questions in other subjects:

Konu
Mathematics, 01.09.2019 18:20
Konu
Mathematics, 01.09.2019 18:20