Advertisement
Guest User

kod

a guest
May 26th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. package ThirdLesson;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Conventor {
  6. public static void main(String[] args) {
  7. Scanner scan = new Scanner(System.in);
  8. double input = Double.parseDouble(scan.nextLine());
  9. String from = scan.nextLine();
  10. String to = scan.nextLine();
  11.  
  12. if (from.equals("mm")) {
  13. input /= 1000;
  14. } else if (from.equals("cm")){
  15. input /= 100;
  16. } else if (from.equals("mi")){
  17. input /= 0.000621371192;
  18. } else if (from.equals("in")){
  19. input /= 39.3700787;
  20. } else if (from.equals("km")){
  21. input /= 0.001;
  22. } else if (from.equals("ft")){
  23. input /= 3.2808399;
  24. } else if (from.equals("yd")){
  25. input /= 1.0936133;
  26. }
  27.  
  28. if (to.equals("mm")) {
  29. input *= 1000;
  30. } else if (to.equals("cm")){
  31. input *= 100;
  32. } else if (to.equals("mi")){
  33. input *= 0.000621371192;
  34. } else if (to.equals("in")){
  35. input *= 39.3700787;
  36. } else if (to.equals("km")){
  37. input *= 0.001;
  38. } else if (to.equals("ft")){
  39. input *= 3.2808399;
  40. } else if (to.equals("yd")){
  41. input *= 1.0936133;
  42. }
  43. System.out.printf("%.8f %s", input, to);
  44.  
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement