COS 100: Introduction to Programming
Interim 2022
Lab 6: Extra practice
This is an outside-of-class bonus lab to help you prepare for the upcoming exam.Lab 6A: I am leaping
- Task: Prompt the user for a starting year and an ending year, then print out all the leap years in between (inclusive).
- Years divisible by 4 are leap years (e.g., 2004, 2008, 2012, 2016, 2020).
-
Sample run:
Start year? 1997 End year? 2012 2000 2004 2008 2012
- Actually, that's too many leap years. You'll fix this in Lab 6C.
Lab 6B: I am waiting
- Ask the user to enter in the current time and a number of minutes to wait.
- Print out the time when the user is done waiting.
-
Sample run:
Current hour: 10 Current minute: 23 Current am/pm: am Wait for how many minutes: 123 Current time is 10:23 am; 123 minutes later is 12:26 pm.
- Can you handle wait time given as hours and minutes?
Challenge Lab 6C: Leaping more accurately
- Modify Lab 6A as follows.
- Years divisible by 100 are not leap years (e.g., 2100, 2200, 2300), except years divisible by 400 are leap years (e.g., 1600, 2000, 2400).
-
Sample run:
Start year? 2095 End year? 2105 2096 2104
- Can you output in a single line with proper grammar (complete with the Oxford comma)?
-
Sample runs:
Start year? 1997 End year? 2012 2000, 2004, 2008, and 2012. Start year? 2095 End year? 2105 2096 and 2104.