Question: Do this program with only using very basic console input / output , variables, constants, assignments, branches, loops, file I / O , and arrays
Do this program with only using very basic console inputoutput variables, constants, assignments, branches, loops, file IO and arrays concepts. Make everything within the int main function. DO NOT MAKE SEPERATE FUNCTIONS. Create a C program to read dates from the console or data file. The dates have to be between January
and December
For each date, determine what day of the week this date falls on If the date falls outside the valid range,
do not process it Output an appropriate error message: For example, for the message should
be "ERROR: is outside of range".
You may assume that the daymonth will be integers greater than and that the combination will be valid,
ie there will not be a month or day or any invalid combination of the two. Months and days
will have a leading if needed.
Ask the user if they wish to input dates via the console window or process dates out of a data file. If the
user selects the console, allow them to enter any number of dates until they enter DONE.
How do you want to provide the data? Console, or File: C
Enter date mmddyyyy or DONE:
If they select a data file, process the supplied data file named PgmData.txt until all dates are processed.
There will not be DONE at the end of the file. Create an output file called PgmOutput.txt containing all
processed dates and appropriate error messages for dates falling outside the required range. Assume dates
in range will be in proper date format, ie mmddyyyy where mmonth, dday, and yyear digits.
If the provided date is then the program's output should be:
July falls on a Tuesday days
If the provided date is then the program's output should be:
February falls on a Thursday days
Note that your program must determine if a given year is a leap year to determine the number of days in
the date's month. You will also use a specific algorithm to find the day of the week, given a date in the
described format.
What Day of Week is it Algorithm Using date
Take the last two digits of the year and add a quarter onto itself. Example: is the year,
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 onedimensional 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 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 it is
Add the numbers from steps and together NOTE: For leap years, subtract
only if the month is January or February.
Take away or multiples of until a number between is left. Hint: Use modulus.
The number you get from the above computations corresponds to the day of the week. Sunday,
Monday, Tuesday, etc. For the example of the value which implies Tuesday.
Algorithm to Find Days in a Month
January, March, May, July, August, October, and December all have days.
April, June, September, and November all have days.
February has days in nonleap years and in leap years.
Algorithm to Find Leap Year
Evenly divisible by noncentury years ie not evenly divisible by are leap.
Evenly divisible by century years that are also evenly divisible by 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 AfflackBpgm for his program solution.
Your solution MUST meet these additional requirements:
Use only ONE dowhile 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 onedimensional array of integers to store the special code, as shown in the above table.
Use ONE switch statement to assign the dayofweek name based on the computed dayofweek
value eg "Sunday"
Use ONE ifelseif statement to assign the month name
Use ONE ifelseif 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 foundJan Feb Mar Apr. May Jun Jul Ago Sept Oct Nov Dec
Open and close files only if the user selects file input and the files were opened
None of the implementations in requirements through can be used more than once you cannot compute leap year more than once, you cannot have two ifelseif statements assigning month name
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
