java语言程序设计(基础篇)第十版编程练习题[2.7]

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

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package dome2_7;

import java.util.Scanner;

/**
 *
 * @author Administrator
 */
public class Dome2_7 {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner in = new Scanner(System.in);
        System.out.print("Enter the number of minutes:");
        int minutes = in.nextInt();
        int years = minutes / (365 * 24 * 60);
        int days = minutes % (60 * 24 * 365) / 60 / 24;
        System.out.println(minutes + " minutes is approximately " + years +" years and " + days +" days");
    }
    
}

你可能感兴趣的:(java源码)