Prev Up Next
Go backward to 6.5 Fibonacci Sequence
Go up to 6 Labs
Go forward to 6.7 Decision Trees and Modulus Arithmetic

6.6 Robots

You are in charge of a moon colonization program. It has been determined that the only way to do the project is with robots. The robots know how to build more robots. After there are enough robots people can also be sent to the moon.

Each robot collects materials for two (2) months. During this time it has collected enough materials to build three (3) robots. It takes one month to build a robot. As soon as it is built (and running) it starts collecting materials to build robots its self.

Write a program that computes the number of robots and keeps track of what they are doing each month. Stop collecting new material for robots when you have 200 robots. This means that some robots will move directly from being built to being idle. So if the total number of robots at the end of one month exceeds 200, no robots should start collecting the following month. If a robot had started collecting material, let the robot complete its cycle. Start with one robot.

Make sure that your program runs until all of the robots are idle. Mark your output with:

Place the lab in the instructor hand in box in BUS R6E, the "terminal room".
Instructor: ltaber@pima.edu** Red's Home page** The Pima College Site

Prev Up Next