Minutes to Hours and Minutes
Programming Basics · Java
TASK
Problem
Read a non-negative number of minutes. Print full hours and the remaining minutes separated by a space.
EXAMPLE
Example
130
2 10
LIMITS
Constraints
0 ≤ minutes ≤ 10^9
LEARN
Theory for this problem
+
The core idea of **Minutes to Hours and Minutes** is to model the requested operation directly: Read a non-negative number of minutes. Print full hours and the remaining minutes separated by a space. The reference solution uses `Scanner` for input. Keep only the state needed for this result, choose numeric types that cover the stated bounds, and preserve the exact input/output contract. This makes the solution easier to verify on boundary cases and avoids unrelated work.
NEED HELP?
Hints
+
['Follow the statement for **Minutes to Hours and Minutes** literally and identify the smallest state needed to produce its output.', 'The reference solution relies on `Scanner` for input; test the smallest allowed input and one boundary case from the constraints.']
ANSWER
Solution
+
// CodeMaster — Minutes to Hours and Minutes
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int minutes = sc.nextInt();
int hours = minutes / 60;
int rest = minutes % 60;
System.out.println(hours + " " + rest);
}
}