A simple console-based countdown timer written in Java.
The program allows the user to enter hours, minutes, and seconds, then counts down in real time while updating the display on a single console line.
This program shows my learning of for loops, .flush and thread handling.
- Accepts user input for hours, minutes, and seconds
- Converts all time into total seconds for accurate countdown logic
- Displays remaining time in
HH:MM:SSformat - Updates the countdown on the same line (no console spam)
- Uses
Thread.sleep(1000)for real-time countdown - Beginner-friendly and easy to understand
- The user enters hours, minutes, and seconds
- The program converts the input into total seconds
- A countdown loop runs from the total seconds down to zero
- Each second:
- The remaining time is recalculated
- The console line is overwritten using
\r - Output is flushed to ensure immediate display
- When the timer reaches zero, the program ends
- Java
- Scanner (user input)
- Console output (
System.out.printf) - Thread handling (
Thread.sleep)
Kaelin Kesavjee