-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMinutesToYear.java
More file actions
45 lines (38 loc) · 1.61 KB
/
MinutesToYear.java
File metadata and controls
45 lines (38 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
Rahim Siddiq
Apr 13 2023
Find the number of years
*/
import java.util.Scanner;
public class MinutesToYear
{
public static void main(String[] args)
{
// Program variables
long minutes = 0;
long years = 0;
long days = 0;
// Conversion variables
long minutesPerDay = 24 * 60;
long daysPerYear = 365;
// Title of program and description of program function to user
System.out.println();
System.out.println(" ====================================================================");
System.out.println(" ========================= MINUTES IN A YEAR ========================");
System.out.println(" ====================================================================");
System.out.println(" Program converts time entered in minutes to number of years/days");
System.out.println(" --------------------------------------------------------------------");
System.out.println();
Scanner input = new Scanner(System.in);
// Prompt for user input
System.out.print(" Enter the number of minutes, then press the [Enter] key: ");
minutes = input.nextLong();
// Calculations and conversions years calculated to floor value and remainder expressed as days
years = minutes / (minutesPerDay * daysPerYear);
days = (minutes % (minutesPerDay * daysPerYear)) / minutesPerDay;
// Display output to user
System.out.println(" --------------------------------------------------------------------");
System.out.print(" " + minutes + " minutes is approximately " + years + " years and " + days + " days.");
input.close();
}
}