SHARE
TWEET

Untitled

a guest Sep 4th, 2017 136 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.company;
  2.  
  3. import java.math.BigDecimal;
  4. import java.util.Scanner;
  5.  
  6. public class Main {
  7.  
  8.  
  9.         public static void main(String[] args) {
  10.             Scanner input = new Scanner(System.in);
  11.  
  12.             double size = input.nextDouble();
  13.             String sourceMetric = input.next().toLowerCase();
  14.             String destinationMetric = input.next().toLowerCase();
  15.  
  16.             if (sourceMetric.equals("km")) size = size / 0.001;
  17.             if (sourceMetric.equals("mm")) size = size / 1000;
  18.             if (sourceMetric.equals("cm")) size = size / 100;
  19.             if (sourceMetric.equals("mi")) size = size / 0.000621371192;
  20.             if (sourceMetric.equals("in")) size = size / 39.3700787;
  21.             if (sourceMetric.equals("ft")) size = size / 3.2808399;
  22.             if (sourceMetric.equals("yd")) size = size / 1.0936133;
  23.             if (destinationMetric.equals("km")) size = size * 0.001;
  24.             if (destinationMetric.equals("mm")) size = size * 1000;
  25.             if (destinationMetric.equals("cm")) size = size * 100;
  26.             if (destinationMetric.equals("mi")) size = size * 0.000621371192;
  27.             if (destinationMetric.equals("in")) size = size * 39.3700787;
  28.             if (destinationMetric.equals("ft")) size = size * 3.2808399;
  29.             if (destinationMetric.equals("yd")) size = size * 1.0936133;
  30.  
  31.             System.out.printf("%f %s", size, destinationMetric);
  32.         }
  33.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top