public class CountDown
1: //CountDown.java
2:
3: import java.util.Scanner;
4:
5: public class CountDown
6: {
7: private int count;
8:
9: public static void main(String[] args)
10: {
11: CountDown countDowner = new CountDown();
12: countDowner.getCount();
13: countDowner.showCountDown();
14: }
15:
16: public void getCount()
17: {
18: System.out.println("Enter a positive integer:");
19: Scanner keyboard = new Scanner(System.in);
20: count = keyboard.nextInt();
21: if (count <= 0)
22: {
23: System.out.println("Input must be positive.");
24: System.out.println("Try again.");
25: getCount();//start over
26: }
27: }
28:
29: public void showCountDown()
30: {
31: System.out.println("Counting down:");
32: for (int left = count; left >= 0; left--)
33: System.out.print(left + ", ");
34: System.out.println("Blast Off!");
35: }
36: }