下面是一个运行示例:
Enter the number of minutes(输入分钟数): 100000000
100000000 minutes is approximately 1902 years and 214 days(十亿分钟近似1902年214天)
package Second;
import java.util.Scanner;
public class Seconds {
public static void main(String[] args) {
System.out.println("Enter the number of minutes:");
Scanner input = new Scanner(System.in);
int minutes = input.nextInt();
int years = 0,days = 0;
years = minutes / (365 * 24 * 60) ;
days = minutes / (24 * 60) % 365;
System.out.println(minutes +" minutes"+ " is approximately " + years +" year"+ " and " + days + " days");
}
}
输出
Enter the number of minutes: 1000000000 1000000000 minutes is approximately 1902 year and 214 days