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 A = Double.parseDouble(scanner.nextLine());
- String B = scanner.nextLine();
- String C = scanner.nextLine();
- if (B.equals("mm")){
- A = A / 1000;
- }else if (B.equals("cm")){
- A = A / 100;
- }
- if (C.equals("mm")){
- A = A * 1000;
- }else if (C.equals("cm")){
- A = A * 100;
- }
- System.out.printf("%.3f",A);
- }
- }
Add Comment
Please, Sign In to add comment