-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHash2.java
More file actions
50 lines (39 loc) · 1.75 KB
/
Copy pathHash2.java
File metadata and controls
50 lines (39 loc) · 1.75 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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import java.util.HashMap;
import java.util.Scanner;
class hash2{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
HashMap <String, String> movielist = new HashMap<>();
// Add Movies
movielist.put("Master", "Screen 1 ");
movielist.put("Retro", "Screen 2 ");
movielist.put("Kalki", "Screen 3 ");
movielist.put("War 2", "Screen 4");
movielist.put("Coolie", "Screen 5");
// System.out.println("Master Movie is playing on : "+ movielist.get("Master"));
// System.out.println("Retro Movie is playing on : "+ movielist.get("Retro"));
// System.out.println("kalki Movie is playing on : "+ movielist.get("kalki"));
// System.out.println("War 2 Movie is playing on : "+ movielist.get("War 2"));
// System.out.println("Coolie Movie is playing on : "+ movielist.get("Coolie"));
// Check for a Movie using if contiion & Scanner
// To get the input
System.out.println("Enter Movie Name : ");
String movlist = scan.nextLine();
// Set var for if & connet the input
String Sermov = movlist;
if (movielist.containsKey(Sermov))
{
System.out.println(Sermov + " This Movie playing on " + movielist.get(Sermov));
}
else
{
System.out.println(Sermov + " This Movie Not Avalivable ");
}
// Display all movies
System.out.println("\nAll Today Playing Movies :");
for(String name : movielist.keySet())
{
System.out.println("Movie: " + name + " Location : " + movielist.get(name));
}
}
}