Ad

HTML
<!DOCTYPE html>
<html>
<head>
    <title>Leap Year Checker</title>
    <link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
    <h1>Leap Year Checker</h1>
    <form>
        <label for="year">Enter a year:</label>
        <input type="number" id="year" placeholder="e.g., 2023">
        <button type="button" onclick="checkLeapYear()">Check</button>
    </form>
    <p id="result"></p>
    <script src="script.js"></script>
</body>
</html>
CSS
body {
    font-family: Arial, sans-serif;
    text-align: center;
}

h1 {
    color: #333;
}

form {
    margin-top: 20px;
}

label {
    font-weight: bold;
}

input[type="number"] {
    padding: 5px;
}

button {
    padding: 5px 10px;
    background-color: #007bff;
    color: #fff;
    border: none;
    cursor: pointer;
}

button:hover {
    background-color: #0056b3;
}

#result {
    font-weight: bold;
    margin-top: 10px;
}
JAVA
import java.util.Scanner;

public class LeapYearChecker {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.print("Enter a year: ");
        int year = scanner.nextInt();

        if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) {
            System.out.println(year + " is a leap year.");
        } else {
            System.out.println(year + " is not a leap year.");
        }

        scanner.close();
    }
}
PYTHON
year = int(input("Enter a year: "))

if (year % 4 == 0 and year % 100 != 0) or year % 400 == 0:
    print(f"{year} is a leap year.")
else:
    print(f"{year} is not a leap year.")

Post a Comment

Previous Post Next Post

Ad