Import java. util. collections;
Public class hanoitest {
Public hanoitest (){
}
Public static void move (string from, string ){
System. Out. println ("Move the top plate from" + from + "to" + );
}
Public static void execute (int n, string from, string temp, string ){
If (n = 1 ){
Move (from, );
} Else {
Execute (n-1, from, to, temp );
Move (from, );
Execute (n-1, temp, from, );
}
}
/**
* @ Param ARGs
*/
Public static void main (string [] ARGs ){
// Todo auto-generated method stub
Optional SC = NULL;
Try {
SC = new centers (system. In );
System. Out. Print ("Enter the initial number of plates on the Tower :");
While (SC. hasnext ()){
String S = SC. nextline ();
If (! S. Matches ("// D + ")){
System. Out. println ("incorrect input. Please enter a number! ");
}
Int n = integer. parseint (s );
Execute (n, "A", "B", "C ");
System. Out. Print ("Enter the initial number of plates on the Tower :");
}
} Catch (exception e ){
E. printstacktrace ();
} Finally {
SC. Close ();
System. Out. println ("end! ");
}
}
}