Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package ThirdLesson;
- import java.util.Scanner;
- public class Conventor {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- double input = Double.parseDouble(scan.nextLine());
- String from = scan.nextLine();
- String to = scan.nextLine();
- if (from.equals("mm")) {
- input /= 1000;
- } else if (from.equals("cm")){
- input /= 100;
- } else if (from.equals("mi")){
- input /= 0.000621371192;
- } else if (from.equals("in")){
- input /= 39.3700787;
- } else if (from.equals("km")){
- input /= 0.001;
- } else if (from.equals("ft")){
- input /= 3.2808399;
- } else if (from.equals("yd")){
- input /= 1.0936133;
- }
- if (to.equals("mm")) {
- input *= 1000;
- } else if (to.equals("cm")){
- input *= 100;
- } else if (to.equals("mi")){
- input *= 0.000621371192;
- } else if (to.equals("in")){
- input *= 39.3700787;
- } else if (to.equals("km")){
- input *= 0.001;
- } else if (to.equals("ft")){
- input *= 3.2808399;
- } else if (to.equals("yd")){
- input *= 1.0936133;
- }
- System.out.printf("%.8f %s", input, to);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement