Write a C++ program which allows the user to play the game "Tower of Hanoi" with 8 disks. See https://en.wikipedia.org/wiki/Tower_of_Hanoi for rules of the game. We use the following conventions.

  • The game is played with 8 disks of different sizes and on 3 towers labeled 1, 2, 3.
  • At the start, all disks are on tower 1 (with the largest disk at the bottom).
  • If the user enters x, y, then the top disk of tower x is moved to the top of tower y.
  • The game is won if all disks are at tower 3.
  • The game is implemented in C++ using screen output to visualize the current state and keyboard input for moving the disks. If the user inputs an incorrect move, there should be an error message and he should be asked to repeat the input. When the game is won, there should be a corresponding message and the program should stop.

Here is an example of the screen output during a game: see image.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.