public class CountDown
1: //CountDown.java
2:
3: import java.util.*;
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 number:");
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: int left;
32: System.out.println("Counting down:");
33: for (left = count; left >= 0; left--)
34: System.out.print(left + ", ");
35: System.out.println("Blast Off!");
36: }
37: }
38:
39:
40:
41:
42:
43: