A class that prices by tier.
Combine class state with tiered conditional logic to compute prices that depend on category, quantity, or membership level.
Pricing problems are a classic AP FRQ. The class holds state (item type, quantity, member status); the pricing method uses an if/else if ladder to compute the right cost.
This pattern combines complete-class design with tiered conditional logic and sometimes boolean surcharges or discounts.
On the AP exam, pricing FRQs appear in shop/membership/ticket scenarios.
State drives the tier; tier drives the price.
Standard pricing pattern.
Membership class
public class Membership {
private String level; // "bronze", "silver", "gold"
private boolean isStudent;
public Membership(String level, boolean isStudent) {
this.level = level;
this.isStudent = isStudent;
}
public double monthlyCost() {
double base;
if (level.equals("gold")) base = 50;
else if (level.equals("silver")) base = 30;
else base = 15; // bronze
double discount = isStudent ? 5 : 0;
return base - discount;
}
public String getLevel() { return level; }
public void upgrade(String newLevel) { this.level = newLevel; }
}
The base cost comes from a three-tier ladder. The student discount is a simple boolean adjustment. Total returned in one step.
Pattern recap
- Determine base via tiered if/else.
- Apply surcharge or discount.
- Combine and return.
Pricing vocabulary.
Used in shop/ticket FRQs.
- Tier — discrete price level.
- Base cost — price from the tier.
- Discount — subtracted from base.
- Surcharge — added to base.
- Total — base ± adjustments.
How pricing classes are tested.
Ladder order and discount placement dominate.
- Ladder ordered correctly. Highest tier first, or per spec.
- Discount/surcharge separate. Cleaner than baking into each branch.
- Use
.equals()for level strings. - Default branch. Catches unrecognized level.
Compute prices for various members.
Different tiers, different discounts.
Using the Membership class above:
- new Membership("gold", false).monthlyCost() → 50 - 0 = 50.
- new Membership("gold", true).monthlyCost() → 50 - 5 = 45.
- new Membership("silver", true).monthlyCost() → 30 - 5 = 25.
- new Membership("bronze", false).monthlyCost() → 15.
- new Membership("bronze", true).monthlyCost() → 10.
Pricing-class pitfalls.
String comparison and missing discount.
==on level strings. Use.equals().- Discount duplicated in each tier. Compute once and apply.
- Returning base instead of total. Forgetting to apply the discount.
- Missing final else. Some inputs fall through with no value.
Pricing class structure.
Tier + adjustment + return.
Pricing Class Reference
AP Quick Reference| Step | Source | Operation |
|---|---|---|
| Determine base | Tier field | if/else if |
| Apply adjustment | Boolean field | Add or subtract |
| Return total | Local sum | Single return |
How to master pricing classes.
Separate base and adjustment.
- MCQ Practice — trace all (tier, discount) combinations to verify the math.
- Java Lab — write Membership, TicketPrice, ShippingCost classes.
- FRQ Practice — compute base then adjustments; sum at the end.
Practice — attempt these now.
AP-style assessments aligned to this lesson. Time them.
AP CSA Unit 13 Topic 05 Complete Class with Conditional Pricing FRQ Practice
AP-style topic practice assessment