Advertisement
kobelowunche

CS Task 03-04 ( Jan 17, 2019 )

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