Java program to check the birthday and print happy birthday message

www.‮i‬giftidea.com

Here's an example Java program to check the birthday and print a "Happy Birthday" message if the current date is the user's birthday:

import java.time.LocalDate;

public class BirthdayChecker {
    public static void main(String[] args) {
        // Enter the user's birthdate
        int birthDay = 10;
        int birthMonth = 3;
        int birthYear = 1990;

        // Get the current date
        LocalDate currentDate = LocalDate.now();

        // Check if it's the user's birthday
        if (currentDate.getDayOfMonth() == birthDay && 
            currentDate.getMonthValue() == birthMonth) {
            System.out.println("Happy Birthday!");
        }
    }
}

This program uses the LocalDate class from the Java 8 date/time API to get the current date. The user's birthdate is stored as three separate integers for the day, month, and year. The program then checks if the current day and month match the user's birthdate using the getDayOfMonth() and getMonthValue() methods of the LocalDate class. If it's the user's birthday, the program prints a "Happy Birthday!" message to the console.

Note that this program assumes that the user's birthdate is stored as integers for the day, month, and year. In a real-world application, you would likely want to retrieve the user's birthdate from a database or user input form, rather than hard-coding it in the program.