Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CSE 1311 Project 1 Write a program named DayOfWeek that computes the day of the week for any date entered by the user. The user

image text in transcribed
CSE 1311 Project 1 Write a program named DayOfWeek that computes the day of the week for any date entered by the user. The user will be prompted to enter a month, day, century, and year The program will then display the day of the week for that date as a number between 0 and 6, where 0 represents Saturday and 6 represents Friday. The program will also print the alphabetic day of the week (Friday, Saturday, Sunday, etc.) The following example shows what the user will see on the screen: This program calculates the day of the week for any date INPUT DATA Enter month (1-12): 9 Enter day (1-31) 2S Enter century: 19 Enter year of the century: 98 OUTPUT DATA Date is 9/25/1998 The day of the week is 6-Friday Hint: Use Zeller's congruence to compute the day of the week. se all integers for the data types. Zeller's congruence relies on the following quantities j is the century (19 in our example, not the 20t century) k is the year within the century (98) m is the month (9) q is the day of the month (25) The day of the week is determined by the following formula: h q+26m+1/10+k+k/4+j4+5)mod 7 The results of all divisions are truncated by the modulus operator. The value of h will lie between 0 (Saturday) and 6 (Friday). Note: Zeller's congruence assumes that January and February are treated as months 13 and 14 of the previous year, this affects the values of k and m, and possibly the value ofj. For full credit, just read in the four values (month, day, century, and year), plug them into the formula, and print the full date, h, the day of the week. This formula assumes that January and February are mouths 13 and 14 of the previous year. If you want the day of week for 1 12006, you must type in 13 1 2005. (For 2 1 2006, type 14 1 2005 and so on) Run the following 9 sets of data for output: 17 2008 (Should be 0-Sat) 10 3 2008 (Should be 1-Sun) 9 15 2008 (Should be 2-Mon) 8 5 2008 (Should be 3-Tue) 9 13 2006 (Should be 4-Wed) 11 2009 (Should be 5-Thu) must be typed in as 13 1 2008 2 6 2009 (Should be 6-Fri) must be typed in as 14 62008 2 2 2017 (Should be 5-Thu) must be typed in as 14 2 2017 1 10 2000 (Should be 2-Mon) must be typed in as 13 10 1999 Your birth date (Check the Intemet or call your mom to verify this day of week!)

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

Database And Expert Systems Applications 22nd International Conference Dexa 2011 Toulouse France August/September 2011 Proceedings Part 1 Lncs 6860

Authors: Abdelkader Hameurlain ,Stephen W. Liddle ,Klaus-Dieter Schewe ,Xiaofang Zhou

2011th Edition

3642230873, 978-3642230875

More Books

Students also viewed these Databases questions