Write an interactive program to help you count all of the boxes in a room. The program

Question:

Write an interactive program to help you count all of the boxes in a room. The program should begin by asking something like How many unnumbered boxes can you see? Then the program will have you number those boxes from 1 to m, where m is your answer. But remember that each box might have smaller boxes inside, so once the program knows you can see m boxes, it should ask you to open box number 1 and take out any boxes you find, numbering those boxes 1.1, 1.2, and so on. It will also ask you to open box number 2 and take out any boxes you find there, numbering those boxes 2.1, 2.2, and so on. This continues for box 3, 4, and so on, up to m. And, of course, each time you number a box 1.1 or 3.8 or something similar, that box might have more boxes inside. Boxes that reside inside of 3.8 would be numbered 3.8.1, 3.8.2, and so on. At the end, the program should print a single number telling you the total number of boxes in the room.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: