Homework 08. Traveling At Light Speed Java
Здравейте, боря се със задачата но Judge ми дава 70 точки. Опитах всякакво форматиране, но резултата е същия: грашка на тестове 1,4 и 6.
Това е кода ми:
public class demo { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); double kmsForLightYear = 9450000000000.0; double kmPerSec = 300000.0; double lightYears = Double.parseDouble(scanner.nextLine()); double secondsTotal = (lightYears*kmsForLightYear)/kmPerSec; int minutes = (int)secondsTotal/60; secondsTotal%=60; int hours = minutes/60; minutes%=60; int days = hours/24; hours%=24; int weeks = days/7; days%=7;
System.out.printf("%d weeks\n" +
"%d days\n" +
"%d hours\n" +
"%d minutes\n" +
"%d seconds\n",
weeks,days,hours,minutes,(int)secondsTotal);
}
}
Ще съм благодарен, ако някой има идея къде може да е проблема.
Thank you. It is not too complicated if it works :) I guess the problem was in the "doubles" that I am using.