Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. package pl.pl;
  2.  
  3. import java.text.DecimalFormat;
  4. import java.util.Scanner;
  5.  
  6. class Main {
  7.  
  8. private static final DecimalFormat df = new DecimalFormat("#.##");
  9.  
  10. private static String calculate(long sec, String planet) {
  11. final double earth = 31557600;
  12. final double mercury = earth * 0.2408467;
  13. final double wenus = earth * 0.61519726;
  14. final double mars = earth * 1.8808158;
  15. final double yowisz = earth * 11.862615;
  16. final double saturn = earth * 29.447498;
  17. final double uran = earth * 84.016846;
  18. final double neptun = earth * 164.79132;
  19.  
  20. switch ( planet ) {
  21. case "Merkury":
  22. return df.format(sec / mercury);
  23. case "Wenus":
  24. return df.format(sec / wenus);
  25. case "Mars":
  26. return df.format(sec / mars);
  27. case "Jowisz":
  28. return df.format(sec / yowisz);
  29. case "Saturn":
  30. return df.format(sec / saturn);
  31. case "Uran":
  32. return df.format(sec / uran);
  33. case "Neptun":
  34. return df.format(sec / neptun);
  35. case "Ziemia":
  36. return df.format(sec / earth);
  37. default:
  38. return "-1";
  39. }
  40. }
  41.  
  42. public static void main(String[] args) {
  43. Scanner scanner = new Scanner(System.in);
  44. long sec = scanner.nextLong();
  45. scanner.nextLine();
  46. String planet = scanner.nextLine();
  47. System.out.println(calculate(sec, planet));
  48. }
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement