Advertisement
Guest User

Judge Valid

a guest
Apr 1st, 2021
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 KB | None | 0 0
  1.     public static void main(String[] args) {
  2.  
  3.         Scanner scan = new Scanner(System.in);
  4.  
  5.         double digit = Double.parseDouble(scan.nextLine());
  6.         String input = scan.nextLine();
  7.         String output = scan.nextLine();
  8.  
  9.         switch (input) {
  10.             case "mm":
  11.                 digit = digit / 1000;
  12.                 break;
  13.             case "cm":
  14.                 digit = digit / 100;
  15.                 break;
  16.         }
  17.         switch (output) {
  18.             case "mm":
  19.                 digit = digit * 1000;
  20.                 break;
  21.             case "cm":
  22.                 digit = digit * 100;
  23.                 break;
  24.             case "m":
  25.                 digit = digit * 1;
  26.                 break;
  27.         }
  28.         System.out.printf("%.3f", digit);
  29.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement