Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CS2 QTR3 CODING EXERCISE 3 and 4 (Task 03-03 / Task 03-04): Leap Year or Not Leap Year
- A year is considered a leap year if it is divisible by 4 but not by 100, or if it is exactly divisible by
- 400 (then it is a leap year).
- Write a program that will proceed to the processing stage if and only if the input is a 4 – digit year
- and within the valid input range of 1900 and 2999 inclusive. If the conditions are not met, then an
- appropriate error message will be displayed (see sample input / output screen displays).
- Whether the inputted year is valid or not valid, a prompt will be displayed to give an opportunity to
- the program user to decide whether to rerun the program or not. The program will rerun if the user response
- to the prompt is either the letter y or Y.
- Sample input / output screen displays:
- Case 1:
- Not a 4-digit year (i.e., less than 4 digits or greater than 4 digits)
- cs2 qtr3 task 03-03 (leap year or not leap year) / jagjavier Page 1 of 4
- Case 2:
- A 4-digit year, but outside the range (either less than 1900 or greater than 2999)
- Case 3:
- A 4-digit year and within the range
- cs2 qtr3 task 03-03 (leap year or not leap year) / jagjavier Page 2 of 4
- Case 4:
- A 4-digit year but a year between 1900 to 1903 inclusive
- Program constraints that must be followed:
- 1. Strictly follow the “Program Design Proces”.
- 2. Prerequisite to encoding to C++ stage is: a written algorithm in flowchart (Task 03-03).
- 3. During the encoding stage, make sure to edit the 4 lines in the source code template to reflect the
- following data:
- Note: If you are unable to edit the source code template, select in Code::Blocks menu bar File | Properties …
- | uncheck File is read-only
- 4. Save the source code as: <username>task03-04.cpp
- 5. Submit the source code by turning it in through Edmodo.
- cs2 qtr3 task 03-03 (leap year or not leap year) / jagjavier Page 3 of 4
- 1 /*
- 2 Program: CS2 Qtr3 Task 03-04 (leap year or not leap year)
- 3 Programmer: your name
- 4 Section: your section name
- 5 Date: dd monthname yyyy
- 6 */
- Test Data:
- Inputted Upper Limit No. of Leap Years Leap Years Remarks
- 999 N.A. N.A. Not a 4-digit year (less
- than 4 digits)
- 10000 N.A. N.A. Not a 4-digit year
- (greater than 4 digits)
- 1920 5 1904, 1908, 1912, 1916, 1920
- 1972 18 1904, 1908, 1912, 1916, 1920,
- 1924, 1928, 1932, 1936, 1940,
- 1944, 1948, 1952, 1956, 1960,
- 1964, 1968, 1972
- 1900, 1901, 1903 0 N.A. 1900, 1901, and 1903
- are not leap year
- cs2 qtr3 task 03-03 (leap year or not leap year) / jagjavier Page 4 of 4
- ^@v@^
- (:::)
- -“-”-
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement