Test Cases are not passing for TowerofHanoi assignment. What is the problem in my code? It is working fine in dos prompt.
import java.util.Scanner;
public class Main {
public static void main(String str[]){
Scanner sc = new Scanner(System.in);
int input = sc.nextInt();
//towerOfHanoi(3,"S","D","T");
// A is the source, B is the temporary, C is the destination
towerOfHanoi(input,"A","C","B");
}
static void towerOfHanoi(int disc, String source, String destination, String temporary){
if ( disc == 1 )
{
String s = String.format("Moving ring %d from %s to %s",disc,source,destination);
System.out.println(s);
//return;
}
else
{
towerOfHanoi(disc-1,source,temporary,destination);
String s = String.format("Moving ring %d from %s to %s",disc,source,destination);
System.out.println(s);
towerOfHanoi(disc-1,temporary,destination,source);
}
//return;
}
}