Fiveable
💻AP Computer Science A
​

💻AP Computer Science A

FRQ 2 – Class Design
​
Unit 3: Class Creation
​
AP CS A FRQ Types & Units

Each FRQ type tests specific skills taught in particular units. Here's why certain units appear for each question type:

FRQFocusUnitsWhy
FRQ 1Methods and Control Structures1-2Tests method writing, loops, conditionals - foundational programming from Units 1-2
FRQ 2Class Design3Tests class design, constructors, instance variables - all Unit 3 OOP content
FRQ 3Data Analysis with ArrayList4Tests using, analyzing, and manipulating data in an ArrayList - Unit 4 content
FRQ 42D Array4Tests 2D array traversal and manipulation - Unit 4 content

This mapping reflects College Board's exam structure - each FRQ type tests specific skills that are taught in particular units.

Practice FRQ 1 of 61/6

2. The RewardCard class, which you will write, represents a customer loyalty card that accumulates points from purchases and allows the customer to claim rewards. RewardCard objects are created by calls to a constructor with two parameters.

RewardCard objects are created by calls to a constructor with two parameters.

  • The first parameter is a String representing the name of the cardholder. (Precondition: Assume that this value is not null and not empty.)

  • The second parameter is an int representing the number of points required to claim a single reward. (Precondition: Assume that this value will be greater than 0.)

makePurchase

The RewardCard class contains a makePurchase method, which calculates points earned from a purchase and adds them to the card's total points.

  • A double representing the purchase amount in dollars. Assume this value is greater than or equal to 0.0.

  • The card earns 100 points for every full $10.00 spent in the purchase. For example, a purchase of $29.99 earns 200 points, and a purchase of $5.50 earns 0 points.

  • The calculated points are added to the card's total points.

  • The method returns the total points on the card after the purchase has been processed.

Returns an int representing the updated total points.

claimReward

The RewardCard class contains a claimReward method, which attempts to redeem points for a reward.

  • If the card's total points are greater than or equal to the required points threshold (set in the constructor), the threshold amount is subtracted from the total points.

  • In this case, the method returns a string in the format "[name] claimed a reward! Points remaining: [points]", where [name] is the cardholder's name and [points] is the updated total points.

  • If the card's total points are less than the required points threshold, the total points remain unchanged.

  • In this case, the method returns a string in the format "[name] needs [X] more points.", where [X] is the difference between the threshold and the current total points.

Returns a formatted String indicating the result of the claim attempt.

Statement

Return Value (blank if no value)

Explanation

String res;

int pts;

RewardCard card1 = new RewardCard("Alex", 500);

RewardCard card1 is constructed for "Alex" with a threshold of 500 points. The initial total points is 0.

pts = card1.makePurchase(25.50);

200

A purchase of $25.50 earns 200 points (2 full $10s). The total points is now 200.

res = card1.claimReward();

"Alex needs 300 more points."

The total points (200) is less than the threshold (500). The difference is 300.

pts = card1.makePurchase(40.00);

600

A purchase of $40.00 earns 400 points (4 full $10s). The total points is now 600.

res = card1.claimReward();

"Alex claimed a reward! Points remaining: 100"

The total points (600) is >= 500. 500 points are subtracted, leaving 100 points.

res = card1.claimReward();

"Alex needs 400 more points."

The total points (100) is less than the threshold (500). The difference is 400.

RewardCard card2 = new RewardCard("Sam", 200);

RewardCard card2 is constructed for "Sam" with a threshold of 200 points. The initial total points is 0.

pts = card2.makePurchase(15.00);

100

A purchase of $15.00 earns 100 points. The total points is now 100.

pts = card2.makePurchase(12.50);

200

A purchase of $12.50 earns 100 points. The total points is now 200.

res = card2.claimReward();

"Sam claimed a reward! Points remaining: 0"

The total points (200) is >= 200. 200 points are subtracted, leaving 0 points.

Write the complete RewardCard class. Your implementation must meet all specifications and conform to the examples shown in the table.

Timed

00:00

Response auto-saves






Pep

essential ap study content awaits..

Features
Testimonials
Testimonials
start studying →
FRQ Directions
Free Response Question Practice

This practice environment simulates the AP AP Computer Science A Free Response Questions section. Here are some guidelines:

  • Read each question carefully before responding. Pay attention to command verbs like "identify," "explain," "analyze," or "evaluate."
  • Use the timer to practice time management. You can pause, restart, or hide the timer as needed.
  • Mark for Review if you want to come back to a question later.
  • Your responses are saved automatically as you type. You can also use the drawing tool for questions that require diagrams or graphs.
  • Use the toolbar for formatting options like bold, italic, subscript, and superscript.
  • Navigate between questions using the Previous and Next buttons at the bottom of the screen.

Tip: Answer all parts of each question. Partial credit is often available, so even if you are unsure, provide what you know.