/home/caleb/ASDV-Java/MP1_CalebFontenot/src/main/java/com/calebfontenot/mp1_calebfontenot/NumberOfYears.java

/*
 * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
 * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
 */
package com.calebfontenot.mp1_calebfontenot;

import java.util.Scanner;

/**
 *
 * @author caleb
 */
public class NumberOfYears {

    public static void main(String[] args)
    {
        // Define vars
        double NumberOfMinutes;
        double NumberOfYears;
        double NumberOfDays;
        double NumberOfHours;

        // Create Scanner
        Scanner input = new Scanner(System.in);

        // Prompt for input
        System.out.print("Enter the number of minutes: ");
        NumberOfMinutes = input.nextDouble();

        // Calculate
        NumberOfHours = (NumberOfMinutes / 60);
        NumberOfDays = (NumberOfHours / 24);
        NumberOfYears = (NumberOfDays / 365);

        // Big brain math time
        //Subtract 365 from "NumberOfDays" until the number is less than or equal to 365
        while (NumberOfDays >= 365.0) {
            //System.out.println("DEBUG: Subtracting 365 from "+ NumberOfDays);
            NumberOfDays = NumberOfDays - 365;
        }

        // Do the same with hours
        while (NumberOfHours >= 24.0) {
            //System.out.println("DEBUG: Subtracting 24 from "+ NumberOfHours);
            NumberOfHours = NumberOfHours - 24;
        }

        // Print output
        System.out.println((int) NumberOfMinutes + " minutes is approx. :");
        if ((int)NumberOfYears >= 2) {
            System.out.println((int) NumberOfYears + " years,");
        } 
        if ((int)NumberOfYears == 1) {
            System.out.println((int)NumberOfYears+" year.");
            }
        if ((int) NumberOfDays != 0) {
            System.out.println((int) NumberOfDays + " days,");
        }
        if ((int) NumberOfHours != 0) {
            System.out.println((int) NumberOfHours + " hours.");
        }

    }
}