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