-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCountryMap.java
More file actions
24 lines (20 loc) · 813 Bytes
/
Copy pathCountryMap.java
File metadata and controls
24 lines (20 loc) · 813 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import java.util.HashMap;
import java.util.*;
public class CountryMap {
public static void main(String[] args) {
Map<String, String> countryMap = new HashMap<>();
countryMap.put("India", "New Delhi");
countryMap.put("Japan", "Tokyo");
countryMap.put("Pakistan", "Islamabd");
countryMap.put("China", "Beijing");
countryMap.put("Sri lanka", "coloumbo");
Scanner sc = new Scanner(System.in);
System.out.println("Please enter the country name: ");
String country = sc.next();
if(countryMap.containsKey(country)){
System.out.printf("capital of %s is %s ", country,countryMap.get(country));
}else{
System.out.println("Sorry We don't know the capital");
}
}
}