CIS 223
Assignment Number 0-S97

A. The Robot Simulator
B. The PALINDROME PROBLEM

Reading: Begin the readings outlined in Part A of the CIS 223 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 on the CIS 223 web site. Then log on to your SUN 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: When 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.

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 appropriate 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 data requirements table and structure chart (as illustrated in the Friedman/Koffman C++ text), and correct compilation and execution tests.

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: Tuesday, January 28, 1997 (in class).

Return to Previous Page