CIS 083
Assignment Number 0-S98

A. The Robot Simulator
B. The PALINDROME PROBLEM

Reading: Begin the readings outlined in Part A of the CIS 083 Course Syllabus.

Programming: An individual assignment in 3 parts, not to be done in groups.

A. An Introduction to the Robot Simulator:

Read the Robot World information in the Anthology. Then log on to your Unix workstation as you would normally do. Follow the directions on the first page of the manual and experiment for 10 or 15 minutes with the simulator.

Once the robot_world simulator is running, use the half-dozen commands described in the manual to exercise the robot -- to get him (or her, if you wish) to move around, perhaps bump into a few walls, get recharged, pick up and move a toy, etc. NOTE: W hen prompted to indicate whether you will be using the simulator in USER mode or FILE mode, enter a 1 to indicate USER mode.

When you have checked out most of the capability of the robot simulator have the robot do the following before stopping him:

Turn In: When you are all done, print the file robot.log, write your name and course information on the output and turn it in to the lab assistant. Also, on a separate sheet of paper:

  1. List three attributes (somewhat like "personal" characteristics) of the robot.
  2. List three operations related to the robot (things that the robot can do, or things that can happen do the robot).

B. Programming:

Write a program to read in a sequence of positive integers, one at a time, and decide whether or not each integer read is a prime number and/or a palindrome. For each positive integer, p, that is read, first decide whether p is prime and print an appro priate message. Then determine if p is a palindrome and print a message. If your program reads a negative integer, it should print an error message and ignore this value (and go immediately to read another integer). When an input value of 0 is read, your program should display the number of integers processed (excluding the zero) and then stop executing.

Be sure to thoroughly test your program -- carefully choose a set of test cases to test each possible execution path through the program. This will be a lot easier to do if the is_palindrome and is_prime steps are each implemented as separate functions .

NOTE: A palindrome is a number (in this case -- it could also be a word) that reads the same forwards as backwards). For example,

AMANAPLANACANALPANAMA

and

8720278

are palindromes.

Some example messages that your program might print:

For a value of p = 272, the program might print the messages

  • p is not prime
  • p is a palindrome
  • For a value of p = -3, the program might print

  • p is not a valid input value and has been skipped
  • For a value of 37 the program might print

  • p is prime
  • p is not a palindrome
  • Turn In: A structure chart (or similar diagram) illustrating

    If you are unfamiliar with such a diagram, you should refer to the Friedman/ Koffman C++ text [see either a) the Case Study, Section 6.4 of the 2nd Edition, or b) the Case Study in Section 4.8 of the 1st edition). If you prefer not clutter your structu re chart with the interface descriptions, write them out separately instead, see some of the function interface descriptions on pp.301-305 (Section 6.4) of the 2nd Edition. I prefer the separate, tabular descriptions for lots of reasons.

    C. Learn how to access the web (if you don't know how already). Print out some web page -- any page will do.

    Turn In: The web page(s) you printed out.

    Due Date (for all parts): Tuesday, January 27, 1998 (in class).