Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import static java.lang.Math.pow;
- public class Pussel {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- int x,y,n,k,i,j;
- int finalYears,finalDays,finalHours, finalMinutes,finalSeconds;
- double years,seconds,minutes,hours,days;
- double sec_hours = 3600.0;
- double sec_minutes = 60.0;
- double sec_years = 31556926.0;// 31536000.0;
- double sec_days = 86400.0;
- double time, sumK = 0.0,sumN = 0.0;
- boolean exit = true;
- do {
- System.out.println("Ange ett x och y varde mellan 1-60: ");
- x = input.nextInt();
- y = input.nextInt();
- if((x>= 1) & (x <= 60) & (y>= 1) & (y<= 60)) {
- exit = false;
- k = (2*x+2*y)-4;
- n = (x*y)-k;
- for(i=1; i <= k; i++) {
- sumK = sumK + pow(1.001,i);
- }
- for(j=1; j <= n; j++) {
- sumN = sumN + pow(1.01,j);
- }
- time = sumK + sumN;
- System.out.println(time);
- years = time/sec_years;
- time = time % sec_years;
- finalYears = (int) years;
- days = time/sec_days;
- finalDays = (int) days;
- time = time % sec_days;
- hours = time/sec_hours;
- finalHours = (int) hours;
- time = time % sec_hours;
- minutes = time/sec_minutes;
- finalMinutes = (int) minutes;
- time = time % sec_minutes;
- seconds = time;
- finalSeconds = (int) time;
- System.out.println(finalYears +" "+ finalDays +" "+ finalHours +" "+ finalMinutes +" "+ finalSeconds);
- }
- else {
- System.out.println("Fel nummer, forsok igen!");
- }
- } while(exit);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement