Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double number = Double.parseDouble(scanner.nextLine());
- String inputMetric = scanner.nextLine(),
- outputMetric = scanner.nextLine();
- if (inputMetric.equals("mm")) {
- if (outputMetric.equals("cm")) {
- number /= 10;
- } else {
- number /= 1000;
- }
- } else if (inputMetric.equals("cm")) {
- if (outputMetric.equals("m")) {
- number /= 100;
- } else {
- number *= 10;
- }
- } else {
- if (outputMetric.equals("cm")) {
- number *= 100;
- } else {
- number *= 1000;
- }
- }
- System.out.printf("%.3f", number);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement