Check out an informative example of solving a problem with recursion. Read section 7.2, 'More on Recursion', here: Karel7.2.htm. Scroll to the bottom of this page. You want to look particularly at the example in which the robot is trying to locate a mine. This involves the 'findMine()' method.
Here is your task. The user places a robot on an arbitrary corner, say the corner of 11th Street and 8th Avenue. Your task is to place a beeper at the corner of 1st Street and 8th Avenue, and a beeper at the corner of 11th Street and 1st Avenue. Here is a picture of the robot, initially positioned at 11th Street and 8th Avenue, after completing this task:
The program is set up so that the user interactively chooses the robot's initial position. I used Java graphical user interface (GUI) tools, and threads, to make this work. You do not need to understand how to build GUIs or use threads for the AP Exam, but you certainly can read about them if you want to. Here is a picture of the GUI that the user sees upon running the program:
Descriptions of what code you need to write are in the 3 Java source files that you download below.
You can download RectangleFrame.java, RecursiveRobot.java and RobotThread.java to use as starting points in writing your program. Right-click on the links, choose 'Save Target As' and add the '.java' extension to each file name.
This programming assignment is problem 7.5 in Karel J. Robot, A Gentle Introduction to the Art of Object-Oriented Programming in Java by Joseph Bergin, Mark Stehlik, Jim Roberts and Richard Pattis. Chapter 7 of this book can be found here: Karel7.htm.