/**
* program Skel3
* it just loops and loops
* it's a safe start for a small Java program
* modified to use Sedgewick/Wayne StdIn and StdOut classes
*
* files StdIn.class, StdOut.class assumed to be
* either in same directory or in classpath
*
* @date fall 2008
* @author N V Fitton, vfitton@nvcc.edu
*/
public class Skel3 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// string object for user input to control loop
String keysIn;
// replace with your introduction
StdOut.println("\n\t Program introduction...");
do
{
// --- snip ---------------------------------
// --- replace with your programming exercise
StdOut.println("\n\t Program body...\n");
// --- snip ---------------------------------
StdOut.print("\n\t Do it again [y/n]? ");
keysIn = StdIn.readString();
}
while (keysIn.startsWith("y") || keysIn.startsWith("Y"));
// end do loop
// remove whatever remains in StdIn:
// at minimum, there's still a newline
while ((StdIn.readChar()) != '\n')
;
StdOut.print( "\n\t Program ending."
+ " Please press the Enter key...");
while ((StdIn.readChar()) != '\n')
;
}
}
Thursday, October 2, 2008
Skeleton3.java here
This version assumes the availability of the booksite's StdIn.class and StdOut.class.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment