Advertisement
cyecize

Unit converter

Jun 7th, 2022
858
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.91 KB | None | 0 0
  1.     public static void main(String[] args) {
  2.         String t1 = "23:59";
  3.         String t2 = "11:43";
  4.  
  5.         System.out.println(LocalTime.parse(t2).isAfter(LocalTime.parse(t1)));
  6.  
  7.         //SpringApplication.run(Application.class, args);
  8.         Map<String, Double> rates = new HashMap<>();
  9.         rates.put("mm", 0.001);
  10.         rates.put("cm", 0.01);
  11.         rates.put("km", 1000D);
  12.         rates.put("mi", 1609.344);
  13.         rates.put("yd", 0.9144);
  14.         rates.put("ft", 0.3048);
  15.         rates.put("m", 1D);
  16.         rates.put("ly", 9_460_730_472_580_800.00);
  17.  
  18.         Scanner scanner = new Scanner(System.in);
  19.         String metric1 = scanner.nextLine();
  20.         String metric2 = scanner.nextLine();
  21.         double value = Double.parseDouble(scanner.nextLine());
  22.  
  23.         value = value * rates.get(metric1);
  24.         value = value / rates.get(metric2);
  25.  
  26.         System.out.println(value);
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement