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 a = Double.parseDouble(scanner.nextLine());
- Double b=a;
- String x = scanner.nextLine();
- String y = scanner.nextLine();
- Double mm =1000.0;
- Double cm = 100.0;
- Double mi = 0.000621371192;
- Double in = 39.3700787;
- Double km = 0.001;
- Double ft = 3.2808399;
- Double yd = 1.0936133;
- Double m = 1.0;
- if (x.equals("mm")) {
- b = a / mm;
- } else if (x.equals("cm")) {
- b = a / cm;
- } else if (x.equals("mi")) {
- b = a / mi ;
- }else if (x.equals("in")) {
- b = a / in ;
- }else if (x.equals("km")) {
- b = a / km ;
- }else if (x.equals("ft")) {
- b = a / ft ;
- }else if (x.equals("yd")) {
- b = a / yd ;
- } else if (x.equals("m")) {
- b = a/m;
- }
- if (y.equals("mm")) {
- b = b * mm;
- } else if (y.equals("cm")) {
- b = b * cm;
- } else if (y.equals("mi")) {
- b = b * mi ;
- }else if (y.equals("in")) {
- b = b * in ;
- }else if (y.equals("km")) {
- b = b * km ;
- }else if (y.equals("ft")) {
- b = b * ft ;
- }else if (y.equals("yd")) {
- b = b * yd ;
- } else if (y.equals("m")) {
- b = b*m;
- }
- System.out.printf("%.8f",b);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement