The problem Write a program that prompts the user to enter the minutes (e.g., 1 billion), and displays the number of years and days for the minutes. For simplicity, assume a year has 365 days. Here is a sample run:

Enter the number of minutes: 1000000000
1000000000 minutes is approximately 1902 years and 214 days

Breaking it down private static double MINUTES_IN_YEAR = 60 * 24 * 365 ;
public static void main ( String [] Strings ) {
Scanner input = new Scanner ( System . in );
System . out . print ( "Enter the number of minutes: " );
double minutes = input . nextDouble ();
input . close ();
double years = calculateYears ( minutes );
double days = calculateMinutes ( minutes );
System . out . println (( int ) minutes + " minutes is approximately "
- Math . round ( years ) + " years and " + Math . round ( days )
- " days" );
}
private static double calculateMinutes ( double minutes ) {
double days = ( minutes / 60 / 24 ) % 365 ;
return days ;
}
private static double calculateYears ( double minutes ) {
double years = minutes / MINUTES_IN_YEAR ;
return years ;
}

Output ```
Enter the number of minutes: 30000
30000 minutes is approximately 0 years and 21 days
```

Find the number of years posted by Justin Musgrove on 04 April 2016

Tagged: java, java-exercises-beginner, intro-to-java-10th-edition, and ch2

Share on: Facebook Google+