Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ilialloyd/cee5344a4da799eff585608604437d21 to your computer and use it in GitHub Desktop.
Save ilialloyd/cee5344a4da799eff585608604437d21 to your computer and use it in GitHub Desktop.
Coding Exercise 9: Minutes To Years and Days Calculator
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