Skip Top Navigation Bar

Birthday Reward Mini-Lab

Required Knowledge

This labs require you to write program code to use the following topics. Tutorials for available topics have been linked.

Birthday Reward

You work as a developer for a small coffee shop chain. Customers who sign up for the rewards program receive a special treat on their birthday. To keep customers engaged, the company wants to add a new feature: Whenever a customer's birthday is within the current month, a random reward code will be sent to their email automatically. You will simulate this process using Java.

Program Requirements

  1. Prompts the user to enter their birthday in the format yyyy-mm-dd as a String.
  2. Uses LocalDate objects to see if the user's birth month is the same as the month for today.
  3. If it is, uses Random class to generate a random 5-character reward code consisting of uppercase letters and displays it with a message.
  4. Otherwise, displays a polite message that their birthday is not in the current month.

Sample Output

Eligible for Reward

The following is an example of a person who is eligible for a reward based on their birthday and that it is hypothetically April.

Enter your birthday (yyyy-mm-dd):
2004-04-25
Congratulations! Your birthday is in this month!
Your reward code: XWTEX

Ineligible for Reward

The following is an example of a person who is eligible for a reward based on their birthday and that it is hypothetically April.

Enter your birthday (yyyy-mm-dd):
2004-02-25
Sorry, your birthday is not in the current month. Try again during your birthday month!