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