/* CountDown.java  -  show how to use sleep() and beep() */

public class CountDown {

    public static void main(String[] args) {
        System.out.println("Countdown begins...");
        System.out.println();

        String[] sNumber = new String[] {
                             "Zero",  "One",  "Two", "Three",
                             "Four",  "Five", "Six", "Seven",
                             "Eight", "Nine", "Ten"
                             };

        for (int i = 10; i >= 0; i--) {

            /* Sleep for 1000 milliseconds (one second) */
            sleep(1000);

            /* Display indented number */
            for (int j = 0; j < 10-i; j++)
                System.out.print("  ");
            System.out.println(sNumber[i]);
        }

        /* Play the system 'beep' sound */
        java.awt.Toolkit.getDefaultToolkit().beep();

        System.out.println();
        System.exit(0);
     }

    /* Sleep for n milliseconds */
     public static void sleep(int n) {
        try {
            Thread.sleep(n);
        } catch (InterruptedException e) {
            /* ignore this exception - do nothing */
        }
     }

}
