Advertisement
Guest User

Untitled

a guest
Sep 29th, 2017
492
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. public static void main(String[] args) {
  2. Scanner input = new Scanner(System.in);
  3.  
  4. double size = input.nextDouble();
  5. String sourceMetric = input.next().toLowerCase();
  6. String destinationMetric = input.next().toLowerCase();
  7.  
  8. if (sourceMetric.equals("km")) size = size / 0.001;
  9. if (sourceMetric.equals("mm")) size = size / 1000;
  10. if (sourceMetric.equals("cm")) size = size / 100;
  11. if (sourceMetric.equals("mi")) size = size / 0.000621371192;
  12. if (sourceMetric.equals("in")) size = size / 39.3700787;
  13. if (sourceMetric.equals("ft")) size = size / 3.2808399;
  14. if (sourceMetric.equals("yd")) size = size / 1.0936133;
  15. if (destinationMetric.equals("km")) size = size * 0.001;
  16. if (destinationMetric.equals("mm")) size = size * 1000;
  17. if (destinationMetric.equals("cm")) size = size * 100;
  18. if (destinationMetric.equals("mi")) size = size * 0.000621371192;
  19. if (destinationMetric.equals("in")) size = size * 39.3700787;
  20. if (destinationMetric.equals("ft")) size = size * 3.2808399;
  21. if (destinationMetric.equals("yd")) size = size * 1.0936133;
  22.  
  23. System.out.printf("%f %s", size, destinationMetric);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement