deyanivanov966

04. Metric Converter

Aug 23rd, 2020 (edited)
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.60 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class MetricConverter {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         double A = Double.parseDouble(scanner.nextLine());
  8.         String B = scanner.nextLine();
  9.         String C = scanner.nextLine();
  10.  
  11.         if (B.equals("mm")){
  12.             A = A / 1000;
  13.         }else if (B.equals("cm")){
  14.             A = A / 100;
  15.         }
  16.  
  17.         if (C.equals("mm")){
  18.             A = A * 1000;
  19.         }else if (C.equals("cm")){
  20.             A = A * 100;
  21.         }
  22.         System.out.printf("%.3f",A);
  23.     }
  24. }
  25.  
Add Comment
Please, Sign In to add comment