Computer Science 523
Advanced Programming
Summer 2014, The College of Saint Rose
Countdown BlueJ Project
Click here to download a BlueJ project for Countdown.
Countdown Source Code
The Java source code for Countdown is below. Click on a file name to download it.
/* * Example Countdown: count down from a given number to a Blastoff! * * Jim Teresco, The College of Saint Rose, CSC 202, Fall 2012 * * $Id: Countdown.java 2366 2014-05-20 02:33:22Z terescoj $ */ import javax.swing.JOptionPane; public class Countdown { public static void main(String[] args) { // read in the starting number for our countdown int countdownLength = 0; do { String input = JOptionPane.showInputDialog("Enter a (positive) number for the start of the countdown"); countdownLength = Integer.parseInt(input); } while (countdownLength <= 0); // now we count down for (int seconds = countdownLength; seconds > 0; seconds--) { JOptionPane.showMessageDialog(null, seconds + "..."); } // and finally, it's Blastoff! JOptionPane.showMessageDialog(null, "Blastoff!"); } }