Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package pl.pl;
- import java.text.DecimalFormat;
- import java.util.Scanner;
- class Main {
- private static final DecimalFormat df = new DecimalFormat("#.##");
- private static String calculate(long sec, String planet) {
- final double earth = 31557600;
- final double mercury = earth * 0.2408467;
- final double wenus = earth * 0.61519726;
- final double mars = earth * 1.8808158;
- final double yowisz = earth * 11.862615;
- final double saturn = earth * 29.447498;
- final double uran = earth * 84.016846;
- final double neptun = earth * 164.79132;
- switch ( planet ) {
- case "Merkury":
- return df.format(sec / mercury);
- case "Wenus":
- return df.format(sec / wenus);
- case "Mars":
- return df.format(sec / mars);
- case "Jowisz":
- return df.format(sec / yowisz);
- case "Saturn":
- return df.format(sec / saturn);
- case "Uran":
- return df.format(sec / uran);
- case "Neptun":
- return df.format(sec / neptun);
- case "Ziemia":
- return df.format(sec / earth);
- default:
- return "-1";
- }
- }
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- long sec = scanner.nextLong();
- scanner.nextLine();
- String planet = scanner.nextLine();
- System.out.println(calculate(sec, planet));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement