Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PART B-Java Programming, Data Design, and Data Structures, 45 points We are hire

ID: 3744448 • Letter: P

Question

PART B-Java Programming, Data Design, and Data Structures, 45 points We are hired to implement an interactive dictionary. Our dictionary takes input from users and uses the input as search key to look up values associated with the key. Requirements: - Coding: No hard coding, https://en.wikipedia.org/wiki/Hard coding - Data Source: Store the original data in a set of enum objects. Each keyword, each part of speech, and each definition must be stored in a separate data field. Do not combine them such as storing three parts in one String Data Structure: Use existing data structure(s) or creating new data structure(s) to store our dictionary's data Data Loading: When our program starts, it loads all the original data from the enum objects into our dictionary's data structure. User Interface: A program interface allows users to input search keys and displays returned results. Our program searches the dictionary's data (not the enum objects) for values associated with the search keys. Identical Output: Our program's output must be identical to the complete sample run's output. The complete output is - -

Explanation / Answer


import java.util.*;
public class Search
{
//create enum for all the pa
enum Speech
{
ADJECTIVE("Placeholder [adjective] :To be updated...."),
ADVERB("Placeholder [adverb] : To be updated..."),
CONJUNCTION("Placeholder [conjunction] : To be updated ..."),
INTERJUNCTION("Placeholder [injection] : 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 definit
enum Data
{
LOADING("! Loading data...."),
LOADING COMPLETED("! Loading compleated..."),
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 defination of csc210 used in this program
enum CSC210
{
ADJECTIVE1("CSC210 [adjective]:Comfortable with Objectives 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 vat
List<String> noFilter =new ArrayList<>;
noFilter.add(Speech.ADJECTIVE.value);
noFilter.add(Speech.ADJECTIVE.value);
noFilter.add(Speech.ADVERB.value);
noFilter.add(Speech.CONJECTIVE.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
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.ADJETIVE.value);
adjective.add(Speech.ADJETIVE.value);
List<String> csc210 = new ArrayList<>():
Arrays.stream(CSC210.values()).forEach(speech ->csc210.add(speech.value));
//Generating the dictionary ana mapping the key-value pairs
Map<String, Object> dictionary=new HashMap<>();
dictionary.put("",noFilter);
dictionary.put("distinct",distinct);
dictionary.put("noun", nonu);
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.
System.out.println();
//Taking the input search parameter from user and displaying the required data from the dictionary using the searh 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= s
earch = arr[1]+
System.out.println(" ((List<String>)dictionary.get(search)).stream().forEach(s ->{
System. out. println(" ");
System. out. println(s);
});
System.out.println(" ");
}
}
}