This sample AP CSP Performance Task is intended as a demonstration of a simple program that meets the PT requirements and makes the Written Response questions as easy as possible to answer.

If you submit this sample task to the College Board as your own, you will almost certainly be flagged for cheating.

AP CSP Performance Task Resources

Free Response from 2023 and earlier do not correspond to the current Performance Task design.

RestaurantPicker AP CSP Performance Task

RestaurantPicker features publicly available information about a handful of restaurants at Disney World (name, location, price range). This site is not affiliated with Disney or the College Board.

Sample run (not submitted to the College Board)

1: Magic Kingdom
2: EPCOT
Location number: 1

1: $14.99 and under per adult
2: $15 to $34.99 per adult
3: $35 to $59.99 per adult
4: over $60 per adult
Price range: 4

Be Our Guest Restaurant
Cinderella's Royal Table
The Crystal Palace

Complete program code

Video

The video meets the Create Performance Task requirements. Specifically, the video shows:

The video is in an acceptable format (mov) and does not contain prohibited informaiton (identifying information or voice narration).

Both links are to the same video. The YouTube verison might show ads (YouTube’s, not mine). The Google Drive version should not show ads.

Personalized Project Reference

These 4 code segments were selected to meet the requirements detailed in the instructions above. Each code segment includes notes that explain why the code segment was selected. The notes are NOT part of the actual PPR submitted to the College Board. The actual PPR must not feature any comments.

Procedure i

public void printMatchingRestaurants(String location, int priceRange)
{
    for(int i = 0; i < restaurantNames.length; i++)
    {
        if(restaurantLocations[i].equals(location) &&
                restaurantPriceRanges[i] == priceRange)
        {
            System.out.println(restaurantNames[i]);
        }
    }
}

The procedure (aka: method or function) includes parameters location and priceRange. The values of the parameters have an effect on the functionality of the procedure. Specifically, the values of the parameters determine whether the println statement executes and how many times.

The algorithm in the procedure includes:

Picking a procedure that implements a simple algorithm (as opposed to a complex one) makes some of the possible Written Response questions easier to answer.

As with all of the PPR, you must NOT include any comments. This includes method (procedure) documentation and comments within the code. A single comment in your PPR can cause you to receive a zero for the entire Performance Task. Double check that your code does not include comments.

Well named procedures and variables are allowed. You should name procedures and variables based on their purpose.

Procedure ii

String location = getLocation();

System.out.println();
int priceRange = getPriceRange();

System.out.println();
printMatchingRestaurants(location, priceRange);

The procedure call must be used to accomplish something related to the program. It can’t be meaningless or unrelated to the overall program.

In this case, the call printMatchingRestaurants(location, priceRange); is used to print restaurants that match the specified location and price range. Both the location and price range are obtained from user input.

List i

restaurantNames = new String[]{
        "Aloha Isle",
        "Casey's Corner",
        "The Plaza Restaurant",
        "The Diamond Horseshoe",
        "Be Our Guest Restaurant",
        "Connections Eatery",
        "La Hacienda de San Angel",
        "Le Cellier Steakhouse",
        "Monsieur Paul",
        "Cinderella's Royal Table",
        "The Crystal Palace",
        "Space 220"
};

For the purposes of the PPR, both a Java array and a Java ArrayList are considered a list. (It is very common for programmers to refer to arrays as lists, even if the programming language actually has 2 separate structures.)

This part does NOT require that the code segment be a complete procedure, or even in a procedure.

The code selected MUST store values in an array (or ArrayList). It can set values or add values, but values must go into the structure.

This code is not required to include a loop. The code is required to contribute to the program’s purpose.

The code for the List section is not required to be related to the code in the Procedure section.

List ii

for(int i = 0; i < restaurantNames.length; i++)
{
    if(restaurantLocations[i].equals(location) &&
            restaurantPriceRanges[i] == priceRange)
    {
        System.out.println(restaurantNames[i]);
    }
}

The list used here must be the SAME list as in List i. The grader will have access to your complete program code and might jump through a hoop to determine if this is the case. The best approach is to make it obvious. Use the same name for the list, even if the list is passed as a parameter.

Although not explicitly required, picking a code segment that loops through the list makes some possible Written Response questions easier to answer. Looping through the list also makes it easier to ensure that the code is “being used to manage complexity in your program.”

See Lists as abstractions for further discussion about using a list to manage complexity in a program.

As with the algorithm in the Procedure section, a simple algorithm is better than a complex algorithm.

Sample Written Response answers for Set 1

2024 Written Response Prompts Set 1

Response to question 1

The program accepts input of a number that identifies a specific location in Disney World (ex: 1 for Magic Kingdom, 2 for EPCOT) for which the user wants to find restaurants. The program uses the input to select and display restaurants from a list that are in the requested location.

Response to question 2 (a)

The code inside the loop identifies restaurants that are in the location specified by the parameter location and that have a price range that matches the parameter priceRange. The code displays the names of all matching restaurants.

Response to question 2 (b)

The call printMatchingRestaurants("Magic Kingdom", 1);

causes the println statement to execute at least once, because the program’s lists have at least 1 restaurant in Magic Kingdom that matches the price range.

For the call printMatchingRestaurants("Universal Studios", 3);

the println statement never executes, because the program’s lists only contain restaurants from Disney World, not from Universal Studios.

Response to question 2 (c)

set a boolean variable allValid to true

for each resturantName in the restaurantNames list

    if a call to checkValidity with restaurantName as an argument returns false

        set allValid to false

At the end of the loop, if allValid is true, all of the elements in restaurantNames are considered valid by the other programmer. If allValid is false, at least one of the elements is not considered valid.

Sample Written Response answers for Set 2

2024 Written Response Prompts Set 2

Response to question 1

This program is designed for visitors to Disney World who are looking for restaurants that match specific criteria (location and expected cost). The program displays restaurants in Disney World that match criteria input by the user.

Response to question 2 (a)

The lists restaurantNames, restaurantLocations, and restaurantPriceRanges are parallel. The values at position i in each list correspond to the same restaurant.

The conditional statement checks that the location and price range of the restaurant at index i match the parameters location and priceRange. If the condition evaluates to true, the code displays the corresponding restaurant name.

When the condition evaluates to false, the statement does not display the restaurant name. If the condition was false for every loop execution, the procedure would not display any restaurant names.

Response to question 2 (b)

Response to first part of question

The procedure call is intended to display restaurants with locations and price ranges that match the values of the arguments location and priceRange.

Option 1 for response to second part of question

printMatchingRestaurants(getLocation(), getPriceRange());

The procedure could be called passing the return values from getLocation() and getPriceRange() as arguments, instead of storing them in variables first. The blank lines from the original code would be lost, but the behavior would be otherwise identical.

Option 2 for response to second part of question

It is not possible to write a call that passes different arguments and obtains the same outcome. The values of the arguments location and priceRange were obtained from user input. The purpose of the procedure call is to display restaurants that match the criteria input by the user.

Response to question 2 (c)

The parameters are location and priceRange.

The procedure searches through the parallel lists with restaurant information to identify restaurants that match the specified values for location and priceRange. Passing different arguments for location and priceRange produces different lists of restaurants.

Without the parameters, separate procedures would have to written for every combination of location and price range. For example:

printCheapMagicKingdomRestaurants()

printExpensiveEpcotRestaurants()

This would be tedious just for the 8 current combinations (2 locations * 4 price ranges). It would be nearly impossible as more locations are added.

See Parameters as abstractions for additional discussion of how parameters can be used to manage complexity in a program.

Additional resources

Although not featured in the PPR, the complete program code uses Input validation and Input validation as a String.

Writing and calling methods is the first in a series that describes methods (aka: procedures, functions).

Traversing arrays and lists demonstrates the use of loops to visit elements in lists.

Help & comments

Get help from AP CS Tutor Brandon Horn

Comment on AP CSP Performance Task Sample