SHARE
TWEET

Untitled

a guest Sep 4th, 2017 150 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class p08_Metric_Converter {  // 98/100
  6.     public static void main(String[] args) {
  7.         Scanner input = new Scanner(System.in);
  8.  
  9.         double size = input.nextDouble();
  10.         String sourceMetric = input.next().toLowerCase();
  11.         String destinationMetric = input.next().toLowerCase();
  12.  
  13.         if (sourceMetric.equals("km")) size = size / 0.001;
  14.         if (sourceMetric.equals("mm")) size = size / 1000;
  15.         if (sourceMetric.equals("cm")) size = size / 100;
  16.         if (sourceMetric.equals("mi")) size = size / 0.000621371192;
  17.         if (sourceMetric.equals("in")) size = size / 39.3700787;
  18.         if (sourceMetric.equals("ft")) size = size / 3.2808399;
  19.         if (sourceMetric.equals("yd")) size = size / 1.0936133;
  20.         if (destinationMetric.equals("km")) size = size * 0.001;
  21.         if (destinationMetric.equals("mm")) size = size * 1000;
  22.         if (destinationMetric.equals("cm")) size = size * 100;
  23.         if (destinationMetric.equals("mi")) size = size * 0.000621371192;
  24.         if (destinationMetric.equals("in")) size = size * 39.3700787;
  25.         if (destinationMetric.equals("ft")) size = size * 3.2808399;
  26.         if (destinationMetric.equals("yd")) size = size * 1.0936133;
  27.  
  28.         System.out.println(size + " " + destinationMetric);
  29.     }
  30. }
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