Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is a C++problem HW 2.1: Day of the Week rite a program that, when a given a target date (month, day year) is input,

image text in transcribed
This is a C++problem
HW 2.1: Day of the Week rite a program that, when a given a target date (month, day year) is input, will display the day of the week for that date You waill implement the following algorithm 1 Calculate the day of the week for December 31 of the preceding year by using the follwing formula: 11 which factors in the count of leap years ((year-1),365 + 1(year _ 1)/41-1(year-1) , 100+1(year-1) , 400)%7 where the result has the following interpretation o 0 Sunday o 1: Monday o 2: Tuesday o 3: Wednesday o 4 Thursday o 5 Friday o 6 Saturday Now that you have the day for December 31 of the preceding year, you then calculate (and add to the previous result) the sum of the total number of days n each month preceding the target month Use a avitch statement having fall-through logic for this calculation Eg. if the target month is December the awitch statement will execute the top case which adds the number of days in November to the sum then it falls down to the next case which adds the number of days in October, and so on through January For a target month of January the awiteh statement would add no days For February, you will need to compute whether it has 28 or 29 days by adding one if the year is (divisible by 4 AND not by 100) OR the year is divisible by 400 To this sum, now add the target day of the month Thus number, modulo aeven, is the day of the week for the target date using the above encoding scheme For extra credit, use enun data types (see Gaddis, Section 11.11 133 12 in Sth ed) for the days of the week, each month the montha of the year, and the number of days in KCD xked leap year HW 2.1: Day of the Week rite a program that, when a given a target date (month, day year) is input, will display the day of the week for that date You waill implement the following algorithm 1 Calculate the day of the week for December 31 of the preceding year by using the follwing formula: 11 which factors in the count of leap years ((year-1),365 + 1(year _ 1)/41-1(year-1) , 100+1(year-1) , 400)%7 where the result has the following interpretation o 0 Sunday o 1: Monday o 2: Tuesday o 3: Wednesday o 4 Thursday o 5 Friday o 6 Saturday Now that you have the day for December 31 of the preceding year, you then calculate (and add to the previous result) the sum of the total number of days n each month preceding the target month Use a avitch statement having fall-through logic for this calculation Eg. if the target month is December the awitch statement will execute the top case which adds the number of days in November to the sum then it falls down to the next case which adds the number of days in October, and so on through January For a target month of January the awiteh statement would add no days For February, you will need to compute whether it has 28 or 29 days by adding one if the year is (divisible by 4 AND not by 100) OR the year is divisible by 400 To this sum, now add the target day of the month Thus number, modulo aeven, is the day of the week for the target date using the above encoding scheme For extra credit, use enun data types (see Gaddis, Section 11.11 133 12 in Sth ed) for the days of the week, each month the montha of the year, and the number of days in KCD xked leap year

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

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

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

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

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2014 Nancy France September 15 19 2014 Proceedings Part I Lnai 8724

Authors: Toon Calders ,Floriana Esposito ,Eyke Hullermeier ,Rosa Meo

2014th Edition

3662448475, 978-3662448472

More Books

Students also viewed these Databases questions