Check Day Type (Weekday/Weekend)
This program checks if a day is weekday or weekend.
Problem Statement
Write a Java program that checks if a day number (17) is weekday or weekend.
Source Code
| 1 | public class DayType { |
| 2 | public static void main(String[] args) { |
| 3 | int day = 6; |
| 4 | if(day >= 1 && day <= 5) { |
| 5 | System.out.println("Weekday - Eduinq"); |
| 6 | } else if(day == 6 || day == 7) { |
| 7 | System.out.println("Weekend - Eduinq"); |
| 8 | } else { |
| 9 | System.out.println("Invalid day - Eduinq"); |
| 10 | } |
| 11 | } |
| 12 | } |
Program Output
Weekend - Eduinq
Explanation
day 15 Weekday. - day 67 Weekend. - Else Invalid. Conclusion: Shows how to classify values using if-else ladder.