Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.Map;
- import java.util.Scanner;
- public class Main
- {
- public static void aasd(String a){
- }
- public static void main(String[] args) {
- Scanner read = new Scanner(System.in);
- Map<String,String> city_country = new HashMap<String,String>();
- boolean a = true;
- while (a) {
- System.out.print("Write the name of the city and country like 'city,country' or write 'STOP' for end: ");
- String c = read.next();
- if ((c).equals("STOP"))
- a=false;
- if (a) {
- if (c.contains(",")) {
- String[] strings = c.split(",");
- city_country.put(strings[0], strings[1]);
- }
- else System.out.println("You aren't write country for this city, try again.");
- }
- }
- a=true;
- while (a){
- System.out.print("Write the name of the city or write 'STOP' for end: ");
- String c =read.next();
- if ((c).equals("STOP"))
- a=false;
- if(a){
- if ((city_country.get(c)!=(null)))
- System.out.println("Country: "+city_country.get(c));
- else System.out.println("Country doesn't exist");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement