006-001-002
For Loop: Countdown Program
Easy
Problem Description
for loop: Countdown Program
Learning Objective: Learn repetition using for loops
In this problem, you will create a program that uses a for loop to count down from the given starting number to 1, printing each integer on a separate line, then outputs "Done" to standard output.
Create a program that counts down from the input number to 1.
Input
Line 1: Starting number (integer, 1 to 5)
Output
[start]
[start-1]
...
1
Done
Test Cases
※ Output examples follow programming industry standards
Input:
3
Expected Output:
3 2 1 Done
Input:
5
Expected Output:
5 4 3 2 1 Done
Input:
1
Expected Output:
1 Done
Input:
10
Expected Output:
10 9 8 7 6 5 4 3 2 1 Done
❌ Some tests failed
Your Solution
Current Mode:● My Code
99
1
2
3
4
5
6
7
8
9
10
›
⌄
⌄
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// Write your code here
sc.close();
}
}
0 B / 5 MB
You have 9 free executions remaining
