7.4 Character processing7 Assignments7.2 Fibonacci Series7.3 Robots

7.3 Robots

 

This program will probably use the while loop.

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.

The robot that just finished building the three(3) robots will normally start collecting materials again too.

Stop collecting new material for robots when you have 200 or more robots. Some robots will move directly from being built to being idle. So if the total number of robots at the end of one month equals or 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(1) robot, but use a preprocessor #define statement to set this value.

Write a program that computes the number of robots and keeps track of what they are doing each month.

Print out the number of robots at the beginning of each month. The total should include both old robots and the robots that have just been built and their assignments.

This means that the first month that shows the total number of robots greater than or equal to 200 robots should also show a decline in the number of collecting robots.

Your program need to print the following:

Other requirements:

Hints:

  1. c1=1;
    while( c1+c2+b1+b2+b3 )
      {
      ...
      }
    
  2. Think about the similarities of this program and Fibonacci series program Lab: 7.2. The programs have a lot in common.
  3. Make sure that your program runs until all of the robots are idle.

Study areas:

Extra credit:

Mark your output with:

Please turn your lab in to me, Louis Taber, during class, or slide it under the door of Santa Rita Building room A-115 (my office).


Instructor: Louis Taber, louis.taber.at.pima at gmail dot com (520) 206-6850
My web site in Cleveland, OH
The Pima Community College web site

7.4 Character processing7 Assignments7.2 Fibonacci Series7.3 Robots