Store the original data in a set of enum objects.


import java.util.*;
public class Search {
//create enum for all the parts of
speech
enum Speech
{
ADJECTIVE("Placeholder
[adjective] : To be updated..."),
ADVERB("Placeholder
[adverb] : To be updated..."),
CONJUNCTION("Placeholder
[conjunction] : To be updated..."),
INTERJUNCTION("Placeholder
[interjunction] : To be updated..."),
NOUN("Placeholder
[noun] : To be updated..."),
PREPOSITION("Placeholder
[preposition] : To be updated..."),
PRONOUN("Placeholder
[pronoun] : To be updated..."),
VERB("Placeholder
[verb] : To be updated...");
private
String value;
Speech(String s) {
this.value
= s;
}
public
String getValue() {
return
value;
}
};
//creating enum for definitions used in this
program
enum Data
{
LOADING("!
Loading data..."),
LOADING_COMPLETED("!
Loading completed..."),
PRINT("-----DICTIONARY
340 JAVA----"),
OOPS("<2nd
argument must be a part of a speech or
\"distinct\""),
SEARCH("Search:
");
private
String value;
Data(String s) {
this.value
= s;
}
public
String getValue() {
return
value;
}
};
//creating enum for all the definitions of
CSC210 used in this program
enum CSC210
{
ADJECTIVE1("CSC210
[adjective] : Comfortable with Objects and
Classes"),
ADJECTIVE2("CSC210
[adjective] : Ready for CSC 220"),
NOUN("CSC210
[noun]Intro to Java "),
VERB("CSC210
[verb] : To learn Java");
private
String value;
CSC210(String s) {
this.value
= s;
}
public
String getValue() {
return
value;
}
};
public static void main(String[]
args) {
System.out.println(Data.LOADING.getValue());
//Generating all the
values required in the dictionary by using the values from
enum
List<String>
noFilter = new ArrayList<>();
noFilter.add(Speech.ADJECTIVE.value);
noFilter.add(Speech.ADJECTIVE.value);
noFilter.add(Speech.ADVERB.value);
noFilter.add(Speech.CONJUNCTION.value);
noFilter.add(Speech.INTERJUNCTION.value);
noFilter.add(Speech.NOUN.value);
noFilter.add(Speech.NOUN.value);
noFilter.add(Speech.NOUN.value);
noFilter.add(Speech.PREPOSITION.value);
noFilter.add(Speech.PRONOUN.value);
noFilter.add(Speech.VERB.value);
List<String>
distinct = new ArrayList<>();
Arrays.stream(Speech.values()).forEach(speech
-> distinct.add(speech.value));
List<String> noun =
new ArrayList<>();
noun.add(Speech.NOUN.value);
noun.add(Speech.NOUN.value);
noun.add(Speech.NOUN.value);
List<String>
nounDistinct = new ArrayList<>();
nounDistinct.add(Speech.NOUN.value);
List<String>
adjective = new ArrayList<>();
adjective.add(Speech.ADJECTIVE.value);
adjective.add(Speech.ADJECTIVE.value);
List<String> csc210
= new ArrayList<>();
Arrays.stream(CSC210.values()).forEach(speech
-> csc210.add(speech.value));
//Generating the
dictionary and mapping the key-value pairs
Map<String,
Object> dictionary = new
HashMap<>();
dictionary.put("",noFilter);
dictionary.put("distinct",
distinct);
dictionary.put("noun",
noun);
dictionary.put("noundistinct",
nounDistinct);
dictionary.put("adjective",
adjective);
dictionary.put("oops",
Arrays.asList(Data.OOPS.getValue()));
dictionary.put("csc210",
csc210);
System.out.println(Data.LOADING_COMPLETED.getValue());
System.out.println();
System.out.println(Data.PRINT.getValue());
System.out.println();
//Taking the input
search parameter from user and displaying the required data from
the dictionary using the search key
while
(true) {
Scanner
reader = new Scanner(System.in);
String
userInput = null;
String
search = null;
System.out.print(Data.SEARCH.getValue());
userInput
= reader.nextLine();
//checking
the number of arguments given by the user and handling the program
accordingly so that it will not break
String[]
arr=userInput.split(" ");
if
(arr.length==1)
search
= "";
else
if (arr.length==2)
search
= arr[1];
else
if (arr.length==3)
search
= arr[1]+arr[2];
System.out.println("
|" );
((List<String>)dictionary.get(search)).stream().forEach(s
-> {
System.out.print("
");
System.out.println(s);
});
System.out.println("
|" );
}
}
}
Q. (a) Given an original set of data, we multiply each number in the set by 2 and then subtract 3 to obtain a new set of data. If the expectation of the new set of data is 7 and the variance is 4, calculate the expectation and variance of the original set of data. (b) Suppose the r.v. X follows Poisson distribution and P(X=1) = P(X=2). Calculate the expectation and variance of X.
In the figure below, Ω is the set of all objects. Black is the
set of all black objects, and White is the set of all white
objects. Square is the set of all square objects, and A is the set
of all objects containing A. Use the relative frequency of
occurrence and the POI (principle of indifference) to answer the
following questions:
Calculate P(A) and P(A|Square). State whether or not A and
Square are independent. State the reason for...
Security Networking (True/False) Hashing is used to reveal the original set of data that has been encrypted.
D Question 12 1.5 pts Check the true statements about NumPy arrays: O A single instantiated NumPy array can store multiple types (e.g., ints and strings) in its individual element positions. A NumPy array object can be instantiated using multiple types (e.g., ints and strings) in the list passed to its constructor O Memory freeing will require a double-nested loop. The number of bits used to store a particular NumPy array object is fixed. O The numpy.append(my.array, new_list) operation mutates...
Create an Enum and call it “Item”. Declare 20 values in the Enum and name them based on your preference. Create a structure called “Order”. Declare an Item and a double for the item price. Create a structure called “Package” where it has an Order pointer, integer for the size, string for the address, package id and bill details. In the main, declare a Package and assign to it more than 3 items. Create a string returning function called “generateBillDetails”...
Exercise 4.3. Counting exchanges and comparisons with Selection Sort Original data set: 60,30,15,51,97,44,37,33 Show how many exchanges and comparisons using the above data set for a selection sort and their totals. Pass Exchanges Comparisons 1 2 3 4 5 6 7 Totals
In a normally distributed data set of how long customers stay in your store, the mean is 44.8 minutes and the standard deviation is 2.6 minutes. Within what range would you expect 95% of your customers to stay in your store? a2.6-44.8 b37.0-52.6 c42.2-47.4 d39.6-50.0
(CO 1) In a normally distributed data set of how long customers stay in your store, the mean is 44.8 minutes and the standard deviation is 2.6 minutes. Within what range would you expect 95% of your customers to stay in your store?
If we select 9 objects from a set of 12 distinct objects, then the number of possible samples is :
(CO 1) In a normally distributed data set of how long customers stay in your store, the mean is 50.3 minutes and the standard deviation is 3.6 minutes. Within what range would you expect 95% of your customers to stay in your store 39.5-61.1 46.7-53.9 43.1-57.5 48.5-52.1