Question: Learning Objectives: You will get practice in this assignment in the following areas in C/C++ : - Writing functions passing parameters - Call functions with



Learning Objectives: You will get practice in this assignment in the following areas in C/C++ : - Writing functions passing parameters - Call functions with parameters - C++ strings - C++ formatted output - Multiple For loops - String Arrays - Integer Arrays - Moderately complex algorithms Description: Your main objective is to write a function that prints out a calendar year. Your program will accept a single input value, that of a 4 digit year. Your program will then write the calendar to standard output starting with January and proceeding through December. You will use the routine that you produced in the previous assignment to produce the individual month print. Programming Specifications: - Upon execution of your program you will prompt the user to input a year equal to or to the year 1582 when the Gregorian calendar was normalized. Your program must make sure that a valid year was entered and values less than 1582 are not allowed. If an invalid year is input you will continue to prompt the user for a year until one is entered. - Your program must recognize when a year is a leap year. A leap year is a year that is divisible by 4 and not 100 unless it is also divisible by 400. - Your program must be able to determine what day of the week the 1st of a month starts on given a year. -. Functions are used and parameters are passed and values returned. Design Considerations: Approach the project in steps. 1. Make sure that your PrintMonth routine works properly before you proceed any further. If you need to do any corrections from Assignment 4, make those corrections first. 2. Write and test the code to read in an integer. Make sure the integer you read in is above 1581 when we started to use the Gregorian Calendar. Continue to ask for a valid number (printing out an error message) until one is entered. I would suggest this as a separate routine that returns the year. 3. Be sure you can determine if the year that is entered is a leap year or not. Is it divisible by 4 and not 100 or divisible by 4 and divisible by 400 . 4. Given a month (112) be sure can determine what day of the week ( 0 through 6) the first starts on for that year. 5. Write the for loop that calls the PrintMonth routine that prints out the months 1 through 12 sending it information on each one on what day the 1st starts on and whether it is a leap year or not. You will most likely need the following routines: // Returns true if the year passed in is a leap year, false otherwise. bool isleapyear (cons int year); // Returns the day of the week the lst starts on given a year and month. int DayofWeek ( const int month, const int year); // Prints the year by calling PrintMonth 12 times. PrintYear (const int year); Required Algorithms: Use the following algorithm to determine what day of the week a date falls on. Use integer division where the remainder is discarded. Do not round off any values or make any modifications to the algorithm. This is actually called zeller's Congruence and is a widely accepted method for calculating the day of the week a date starts on. It works fine. You will have to declare some varibles and add of course syntax such as semicolons. //d,a,y, and m are integers used for interim calculation. You just declare these. // month is the Month (1-12), year is the year, and the day will always be 1. day=1;a=(14month)/12y=yearam=month+12a2d=(day+y+y/4y/100+y/400+(31m/12))%7 The value d will be between 0 and 6.0 is Sunday, 1 is Monday, 2 is Tuesday, 3 is Wednesday, 4 is Thursday, 5 is Friday, 6 is Saturday
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
