Created
September 1, 2022 02:42
-
-
Save ilialloyd/cee5344a4da799eff585608604437d21 to your computer and use it in GitHub Desktop.
Coding Exercise 9: Minutes To Years and Days Calculator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MinutesToYearsDaysCalculator { | |
public static void printYearsAndDays(long minutes){ | |
if (minutes < 0) { | |
System.out.println("Invalid Value"); | |
}else { | |
// make to understand process easy, I go step by step | |
long hour = minutes / 60; //simple find first hours | |
long day = hour / 24; // then go for days | |
long year = day / 365; //then find a years | |
long remaindays= day%365; //then go for remaining days, so, after some years how many days left we will see | |
System.out.println(minutes + " min = " + year + " y and " + remaindays + " d"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment