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