Question: / * MoveTower ( disk , source, dest, spare ) : if disk = = 1 : move disk from source to dest else MoveTower
MoveTower disk source, dest, spare:
if disk :
move disk from source to dest
else
MoveTower disk source, spare, dest
move disk from source to dest
MoveTower disk spare, dest, source
Please use appropriate data types and
also design appropriate output to demonstrate the correctness of your code.
Assume we use characters A B C to denote the source, spare, dest, respectively.
Your output may look as follows:
Please enter the number of disks:
move disk from A to C
move disk from A to B
move disk from C to B
move disk from A to C
move disk from B to A
move disk from B to C
move disk from A to C
Note
DO NOT DELETE ANY COMMENT!!!
You will only need to fill the block with comments "COMPLETE THIS BLOCK".
Modify the file name to "HanoiTower.java" before compiling it
import java.util.Scanner;
public class HanoiTower
public static void mainString args
Scanner input new ScannerSystemin;
System.out.printPlease enter the number of disks: ;
int disk input.nextInt;
call hanoiTower method
hanoiTowerdiskACB;
public static void hanoiTowerint disk, char source, char dest, char spare
choose appropriate data type and update "datatype"
if disk
COMPLETE THIS BLOCK
else
COMPLETE THIS BLOCK
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
