Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.37 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.  
  7.     public static void main(String[] args) {
  8.  
  9.         Scanner scanner = new Scanner(System.in);
  10.  
  11.         double size = Double.parseDouble(scanner.nextLine());
  12.         String sourceMetric = scanner.nextLine().toLower();
  13.         String destMetric = scanner.nextLine().toLower();
  14.  
  15.         if(sourceMetric == "mm")
  16.             size = size / 1000;
  17.         if(sourceMetric == "cm")
  18.             size = size / 100;
  19.         if(sourceMetric == "mi")
  20.             size = size / 0.000621371192;
  21.         if(sourceMetric == "in")
  22.             size = size / 39.3700787;
  23.         if(sourceMetric == "km")
  24.             size = size / 0.001;
  25.         if(sourceMetric == "ft")
  26.             size = size / 3.2808399;
  27.         if(sourceMetric == "yd")
  28.             size = size / 1.0936133;
  29.  
  30.         if(destMetric == "mm")
  31.             size = size * 1000;
  32.         if(destMetric == "cm")
  33.             size = size * 100;
  34.         if(destMetric == "mi")
  35.             size = size * 0.000621371192;
  36.         if(destMetric == "in")
  37.             size = size * 39.3700787;
  38.         if(destMetric == "km")
  39.             size = size * 0.001;
  40.         if(destMetric == "ft")
  41.             size = size * 3.2808399;
  42.         if(destMetric == "yd")
  43.             size = size * 1.0936133;
  44.  
  45.         System.out.println(size + " " + destMetric);
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement