-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSem2_T3_21.java
More file actions
36 lines (34 loc) · 1.28 KB
/
Sem2_T3_21.java
File metadata and controls
36 lines (34 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import java.util.*;
public class Sem2_T3_21 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
Hashtable<String, String> h = new Hashtable<>();
h.put("Dog", "Animal");
h.put("Car", "Vehicle");
h.put("Java", "Computer Language");
System.out.println(h);
String s;
while (true) {
System.out.print("\nEnter the Word U want to find meaning : ");
s = sc.nextLine();
if(h.containsKey(s)) {
System.out.println(s + " Meaning is : " + h.get(s));
} else {
System.out.println("Meaning not Found!!!");
System.out.println("\nWould you like to enter the meaning(yes/no)??");
String q = sc.nextLine();
if (q.equalsIgnoreCase("yes")) {
System.out.print("\nWrite Meaning : ");
String m = sc.nextLine();
h.put(s, m);
}
}
System.out.println("\nDo you want to find more(yes/no)??");
String fm = sc.nextLine();
if (fm.equalsIgnoreCase("no")) {
break;
}
}
System.out.println("\nFinal : " + h);
}
}