栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Java

Java *2.7(求出年数)编写程序,提示用户输入每分钟(例如十亿)然后显示这些分钟代表多少年和多少天。为了简化问题,假设一年有365天。

Java 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Java *2.7(求出年数)编写程序,提示用户输入每分钟(例如十亿)然后显示这些分钟代表多少年和多少天。为了简化问题,假设一年有365天。

下面是一个运行示例:

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

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/884392.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号