Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What Day of Week is it Algorithm ( Using date 7 - 1 3 - 2 0 0 4 ) Take the last two digits

What Day of Week is it Algorithm (Using date 7-13-2004)
Take the last two digits of the year and add a quarter onto itself. (Example: 2004 is the year, 04+1=5)
Hint: Use integer division to get the quarter.
A unique month code will be needed to compute the day of the week and should be stored in an array.
Create a one-dimensional array to hold the month codes, as shown in the below table.
Assign the month code based on the month of your date. Note: if the month is July, the month code used for
computation will be 5(see the arrow in the table above). The code is not the month's number. Use the table
to find the month code needed for a particular month in your date.
Assign the day number to a variable that will hold the day (for 7-13-2004, it is 13).
Add the numbers from steps 1,2, and 3 together (5+5+13=23). NOTE: For leap years, subtract 1
only if the month is January or February.
Take away 7(or multiples of 7) until a number between 0-6 is left. ) Hint: Use modulus.
The number you get from the above computations corresponds to the day of the week. Sunday, 1=
Monday, 2= Tuesday, etc.). For the example of 7-13-2004, the value 2, which implies Tuesday.
Algorithm to Find Days in a Month
January, March, May, July, August, October, and December all have 31 days.
April, June, September, and November all have 30 days.
February has 28 days in non-leap years and 29 in leap years.
Algorithm to Find Leap Year
Evenly divisible by 4 non-century years (i.e., not evenly divisible by 100) are leap.
Evenly divisible by 4 century years that are also evenly divisible by 400 are leap.
Requirements
Make sure to name your project with your last name, first name initial, and "_pgmX" where x is the program number. For
example, a student named Ben Afflack would use AfflackB_pgm1 for his program 1 solution.
Your solution MUST meet these additional requirements:
Use only ONE do-while loop to validate the user's choice of console or file input. The user must
enter C or F only.
Use only ONE while loop to process dates (either from console input or file input).
Use ONE one-dimensional array of integers to store the special code, as shown in the above table.
Use ONE switch statement to assign the day-of-week name based on the computed day-of-week
value (e.g.,0=> "Sunday")
Use ONE if/else-if statement to assign the month name
Use ONE if/else-if statement to assign days for a month
Use modulus in your computation
Do not compute anything if the use selected file but the file is not found
image text in transcribed

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

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

Recommended Textbook for

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

More Books

Students also viewed these Databases questions

Question

Explain methods of metal extraction with examples.

Answered: 1 week ago