question 39 Conditional Logic · hard
Is this a real date?
A booking form gets a year, a month and a day as numbers. Print Bad month for a month outside 1 to 12, Bad day for a day that doesn't exist in that month, and Valid date otherwise. April, June, September and November have 30 days; February has 29 in a leap year and 28 otherwise; the rest have 31. A leap year is divisible by 4, except years divisible by 100, which are leap years only when divisible by 400.
First lines
year = 2024, month = 2 and day = 29. Check runs your program again with other datesPrints
Valid dateOrdercheck the month first
Expected output1 line
- 1Valid date