/home/caleb/ASDV-Java/MP1_CalebFontenot/src/main/java/com/calebfontenot/mp1_calebfontenot/NumberOfYears.java |
nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt
nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java
package com.calebfontenot.mp1_calebfontenot;
import java.util.Scanner;
@author
public class NumberOfYears {
public static void main(String[] args)
{
double NumberOfMinutes;
double NumberOfYears;
double NumberOfDays;
double NumberOfHours;
Scanner input = new Scanner(System.in);
System.out.print("Enter the number of minutes: ");
NumberOfMinutes = input.nextDouble();
NumberOfHours = (NumberOfMinutes / 60);
NumberOfDays = (NumberOfHours / 24);
NumberOfYears = (NumberOfDays / 365);
while (NumberOfDays >= 365.0) {
NumberOfDays = NumberOfDays - 365;
}
while (NumberOfHours >= 24.0) {
NumberOfHours = NumberOfHours - 24;
}
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.");
}
}
}