THINK FIRST·CODE LATER

← All labs

One billion minutes

Problem

MinutesToYears reads a number of minutes (a long, it may be very large) and converts it into years (of 365 days), days, hours and minutes. It also prints the same duration in days only, as a real number.

For the input

1000000000

the program prints

1000000000 minutes is 1902 years, 214 days, 10 hours and 40 minutes
In days only: 694444.4444444445

Work in stages: minutes → hours and remaining minutes; hours → days and remaining hours; days → years and remaining days.

Data for this lab

Your program reads its data from standard input. Download the file, then give it to your program as shown below. Start with data set 1: its expected output is given.

l4-8-data-1.txt

1000000000
What your program must print for l4-8-data-1.txt
1000000000 minutes is 1902 years, 214 days, 10 hours and 40 minutes
In days only: 694444.4444444445

Run your program first, then open this and compare line by line: your output must contain these lines exactly.

How to give the file to my program

Terminal (macOS, Linux, or Windows Command Prompt), after compiling:

java Main < l4-8-data-1.txt

Windows PowerShell does not understand <:

Get-Content l4-8-data-1.txt | java Main

IntelliJ IDEA: Run → Edit Configurations → Redirect input from. Or simply paste the content of the file into the console when the program waits for input.

Write it here or in your IDE, then paste it. Compile and test it yourself before comparing. Your code stays in your browser — it is never sent to or stored on the server.