CIS 254 Intro to Object Oriented Program Design

Project 11.1

No documentation required for this assignment

Write a program that prints a calendar for one year, given the day of the week that January 1 falls on. Each successive month starts on the day of the week that follows the last day of the preceding month. Days of the week will be numbered 0 through 6 for Sunday through Saturday.

This is the first part of a two part assignment using incremental development. The output will not look much like a calendar in part 1. Also, documentation is not required on this assignment. You'll do that in part 2.

Do not use classes, arrays, or structs in this project!! (If you don't know what they are, don't worry, you aren't using them.)

Ultimately, after your next assignment, Your output should look exactly like the one in this sample screen output:

What year do you want a calendar for? 2022
What day of the week does January 1 fall on?
(Enter 0 for Sunday, 1 for Monday, 6 for Saturday, etc.): 4 

       2022

      January

  S  M  T  W  T  F  S
---------------------
              1  2  3
  4  5  6  7  8  9 10
 11 12 13 14 15 16 17
 18 19 20 21 22 23 24
 25 26 27 28 29 30 31

     February

  S  M  T  W  T  F  S
---------------------
  1  2  3  4  5  6  7
  8  9 10 11 12 13 14
 15 16 17 18 19 20 21
 22 23 24 25 26 27 28

        March

  S  M  T  W  T  F  S
---------------------
  1  2  3  4  5  6  7
  8  9 10 11 12 13 14
 15 16 17 18 19 20 21
 22 23 24 25 26 27 28
 29 30 31

        April

  S  M  T  W  T  F  S
---------------------
           1  2  3  4
  5  6  7  8  9 10 11
 12 13 14 15 16 17 18
 19 20 21 22 23 24 25
 26 27 28 29 30

          May

  S  M  T  W  T  F  S
---------------------
                 1  2
  3  4  5  6  7  8  9
 10 11 12 13 14 15 16
 17 18 19 20 21 22 23
 24 25 26 27 28 29 30
 31

         June

  S  M  T  W  T  F  S
---------------------
     1  2  3  4  5  6
  7  8  9 10 11 12 13
 14 15 16 17 18 19 20
 21 22 23 24 25 26 27
 28 29 30

         July

  S  M  T  W  T  F  S
---------------------
           1  2  3  4
  5  6  7  8  9 10 11
 12 13 14 15 16 17 18
 19 20 21 22 23 24 25
 26 27 28 29 30 31

       August

  S  M  T  W  T  F  S
---------------------
                    1
  2  3  4  5  6  7  8
  9 10 11 12 13 14 15
 16 17 18 19 20 21 22
 23 24 25 26 27 28 29
 30 31

    September

  S  M  T  W  T  F  S
---------------------
        1  2  3  4  5
  6  7  8  9 10 11 12
 13 14 15 16 17 18 19
 20 21 22 23 24 25 26
 27 28 29 30

      October

  S  M  T  W  T  F  S
---------------------
              1  2  3
  4  5  6  7  8  9 10
 11 12 13 14 15 16 17
 18 19 20 21 22 23 24
 25 26 27 28 29 30 31

     November

  S  M  T  W  T  F  S
---------------------
  1  2  3  4  5  6  7
  8  9 10 11 12 13 14
 15 16 17 18 19 20 21
 22 23 24 25 26 27 28
 29 30

     December

  S  M  T  W  T  F  S
---------------------
        1  2  3  4  5
  6  7  8  9 10 11 12
 13 14 15 16 17 18 19
 20 21 22 23 24 25 26
 27 28 29 30 31

However, for this assignment, you should just start every month on the same day (the day entered by the user), and just print all of the dates out on a single line. So, the output for this assignment will look like this:

What year do you want a calendar for? 2022
What day of the week does January 1 fall on?
(Enter 0 for Sunday, 1 for Monday, 6 for Saturday, etc.): 4
        2022

       January

  S  M  T  W  T  F  S
---------------------
              1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

      February

  S  M  T  W  T  F  S
---------------------
              1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28

        March

  S  M  T  W  T  F  S
---------------------
              1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

        April

  S  M  T  W  T  F  S
---------------------
              1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

         May

  S  M  T  W  T  F  S
---------------------
              1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

        June

  S  M  T  W  T  F  S
---------------------
              1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

        July

  S  M  T  W  T  F  S
---------------------
              1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

       August

  S  M  T  W  T  F  S
---------------------
              1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

     September

  S  M  T  W  T  F  S
---------------------
              1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

      October

  S  M  T  W  T  F  S
---------------------
              1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

     November

  S  M  T  W  T  F  S
---------------------
              1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

     December

  S  M  T  W  T  F  S
---------------------
              1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

Additional Requirements and Hints:

  1. Your program must determine whether a year is a leap year exactly, not just by checking for divisibility by 4. Also remember that you are free to steal the isLeapYear function from the lessons.

  2. The number of days in each month and the numbers in the leap year formula are not good candidates for using global constants. You should just use the literals directly in your code. However, you SHOULD use global constants for DAYS_IN_WEEK and MONTHS_IN_YEAR. (You won't need DAYS_IN_WEEK for this part of the project, but you'll need it for part 2.)

  3. It is extremely important that you use stepwise refinement when designing this program. Insufficient decomposition may result in a grade of 0.

  4. Required! You MUST have a single function named "printMonth()" that prints out ANY month, given (1) the year, (2) the month number, and (3) the day of week that the month starts on. (Think about why the printMonth() function will need to know the year.) The parameters must be in that order for it to pass the zyBooks tests. For example, don't create 12 separate functions, one named "printJanuary", one named "printFebruary," and so on. In addition, you must have only ONE call to this printMonth() function, in a loop that calls the function 12 times. This printMonth() function must print the entire month, including the month name and header. Also note that in order to pass the zyBooks tests, the printMonth() function must end with two newlines (endl), one to end the line of numbers, and a second one to create the blank line that occurs after each month.

  5. You'll have to get the format just right in order to pass the zyBooks tests. After the user enters the data, the next line should be the year, and then there should be a blank line after the year. Then the printMonth() function must start by printing the month name and end by printing the blank line that separates each month from the following month. This means, for example, that there will be a blank line after the last month is printed.

  6. Let me describe my solution to this problem, not so that you can try to match it exactly, but so that you'll know if you are going way off into the wrong direction. I had 8 functions all together including main(). 4 of them were 5 lines or less. 2 of them were fairly long functions but only because they were switch statements -- hard if not impossible to decompose further. That leaves 2 functions that were 8 - 10 lines long. One of these was the printMonth() function.

    When I count lines I count only the body of the function and I don't count declaration statements or blank lines or comments, but I do count a line if it has only a } on it.

  7. Make sure each of your functions performs a single logical task (not two). If you find yourself trying to name a function with the word AND, it probably means the function should be divided into two.

  8. To print month names, use setw(13). To print the year, use setw(11). They don't need to be centered.