006-004-005
Do-While Loop: Countdown
Easy
Problem Description
Do-while loop: Countdown
In this problem, you will create a program that reads an integer n from standard input, uses a do-while loop to count down from n to 1 printing each number, and displays "Done!" at the end.
Learning Objective: Understand that do-while executes at least once
Overview
The do-while loop checks condition after execution, so the loop body always runs at least once. Let's create a countdown from the input value!
Specifications
- Read integer
nusingScanner - Use do-while for countdown
- Display current number each iteration
- Repeat while count is greater than 0
- Display "Done!" at the end
Input Format
n
n: Starting value for countdown (integer >= 1)
Output Format (when n=3)
3
2
1
Done!
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
Sign Up