Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ please :) First, ask the user to enter a year (4-digit) and what week day does this year starts with (String) For example, the

c++ please :) image text in transcribed
image text in transcribed
image text in transcribed
First, ask the user to enter a year (4-digit) and what week day does this year starts with (String) For example, the year 2018 starts with the week day "Friday". In this case, the calendar should start from January 1 which is Friday, 2018 Your program should produce a formatted calendar for the specified year and there should be a blank line after each month. Moreover, the month and the year should be centered over each month. Your program should reject any year that is less than 1000 or greater than 9999. Your program should handle a leap year correctly Development notes: . You can use the predefined function "setwO" from the library "iomanip". "setwO" allows you to pass a number and your output will be intended the number of spaces you passed to "setw" 2. Before every month, print the week days: "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" 3. Remember that the first day of each month has to be indented to the correct column. The last day of every month determines the first day of the next month. (Hint: Modulus operations make this calculation easy.) 4. To make it easier, you can convert the input string to upper case directly by using the predefined function "toupper)" or to lower case by using "tolower)" 5. To check if a year is a leap year then I If the year is evenly divisible by 4, go to step 2. Otherwise, go to step 5 II. If the year is evenly divisible by 100, go to step 3. Otherwise, go to step 4. III If the year is evenly divisible by 400, go to step 4. Otherwise, go to step 5. IV. The year is a leap year (it has 366 days). V. The year is not a leap year (it has 365 days). 6. You will need to define and implement the following functions: void PrintOneMonth (int MonthNumber, int Year,int StartDayNumber) PRE: MonthNumber,Year, StartDayNumber all in range POST month's calendar printed to output stream, with day headers VO: No input. Output to specified stream (default to screen) USER INTERACTION None ERROR HANDLING: None. Bad input will probably produce screwy output, that hasn't been tested int DaysPerMonth (int MonthNumber, int Year) PRE: MonthNumber, Year in range POST returns days in that month&year, allowing for leap years. O: None USER INTERACTION: None ERROR HANDLING: None. Bad input will probably produce bad results; that hasn't been tested. int GetStartDayNumber *PRE: None POST Returns day of week as int (Sun-0, Mon-, etc) VO: Screen&keyboard, no file /O. User prompts, corrections on range USER INTERACTION Prompts user for day of week Loops until valid correctly-spelled day is input. Input is case-insensitive ERROR HANDLING: Loops until a valid day name is entered. Data is input as string so no problem if number is entered. int GetYear ; PRE:None POST Returns 4-digit number that is assumed to be a year, 1000 Y-9999 VO: Screen/keyboard USER INTERACTION Prompts for year number Expects n teger input ERROR HANDLING: None. Entering non-numeric input will mess things up 7. You can add any parameter to the functions, also you can add more functions if you want. Sample of output Enter year (must be in range 1000 Year

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions