Advertisement
evgenko

Untitled

Sep 4th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.41 KB | None | 0 0
  1. package com.company;
  2.  
  3.  
  4. import java.util.ArrayList;
  5. import java.util.HashMap;
  6. import java.util.Map;
  7. import java.util.Scanner;
  8.  
  9. public class Main
  10. {
  11.     public static void aasd(String a){
  12.  
  13.  
  14.     }
  15.  
  16.     public static void main(String[] args) {
  17.         Scanner read = new Scanner(System.in);
  18.         Map<String,String> city_country = new HashMap<String,String>();
  19.         boolean a = true;
  20.         while (a) {
  21.             System.out.print("Write the name of the city and country like 'city,country' or write 'STOP' for end: ");
  22.             String c = read.next();
  23.             if ((c).equals("STOP"))
  24.                 a=false;
  25.             if (a) {
  26.                 if (c.contains(",")) {
  27.                     String[] strings = c.split(",");
  28.                     city_country.put(strings[0], strings[1]);
  29.                 }
  30.                 else System.out.println("You aren't write country for this city, try again.");
  31.             }
  32.         }
  33.         a=true;
  34.         while (a){
  35.             System.out.print("Write the name of the city or write 'STOP' for end: ");
  36.             String c =read.next();
  37.             if ((c).equals("STOP"))
  38.                 a=false;
  39.             if(a){
  40.                 if ((city_country.get(c)!=(null)))
  41.                     System.out.println("Country: "+city_country.get(c));
  42.                 else System.out.println("Country doesn't exist");
  43.             }
  44.         }
  45.  
  46.  
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement