Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double size = Double.parseDouble(scanner.nextLine());
- String sourceMetric = scanner.nextLine().toLower();
- String destMetric = scanner.nextLine().toLower();
- if(sourceMetric == "mm")
- size = size / 1000;
- if(sourceMetric == "cm")
- size = size / 100;
- if(sourceMetric == "mi")
- size = size / 0.000621371192;
- if(sourceMetric == "in")
- size = size / 39.3700787;
- if(sourceMetric == "km")
- size = size / 0.001;
- if(sourceMetric == "ft")
- size = size / 3.2808399;
- if(sourceMetric == "yd")
- size = size / 1.0936133;
- if(destMetric == "mm")
- size = size * 1000;
- if(destMetric == "cm")
- size = size * 100;
- if(destMetric == "mi")
- size = size * 0.000621371192;
- if(destMetric == "in")
- size = size * 39.3700787;
- if(destMetric == "km")
- size = size * 0.001;
- if(destMetric == "ft")
- size = size * 3.2808399;
- if(destMetric == "yd")
- size = size * 1.0936133;
- System.out.println(size + " " + destMetric);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement