Question: C programming help please!!
Question:
C programming help please!!
Answer:
Functions:
What calls what tree:
int main(int argc, char * argv[])
int checkInput(int year, int month, int day) // returns 0 if ok else 1
int getDaysInMonth(int year, int month) // returns the # of days in month for year
int getFebDays(int year) // returns # of days in February for this year
int getNumDays(int year, int month, int day) // returns # of days in year that given date is
int getFebDays(int year) // same function called again
Function details: Each function must follow the algorithm given below
int main(int argc, char * argv[]) // must use do while and while loops as documented
do
Ask the user to enter a year, a month and a day after 1600.
while checkInput(year, month , day) is error
Ask the user to enter a year, a month and a day after 1600.
end while error
print getNumDays(year, month, day)
Ask user do you want to quit y or n?
while user does not want to quit (does not enter y)
int checkInput(int year, int month, int day) // returns 0 if ok else -1
Print an error message if year is < 1600 or month is not 1 – 12 or day not 1 – correct number for that month and return -1
Else return 0 for no errors
// important only one return statement at the bottom of function
Use if statement for year and month being correct
Calls getDaysInMonth(int year, int month) and use if statement to see if days is correct
int getDaysInMonth(int year, int month) // returns the # of days in month for year
You must use a switch statement on the month to find the number of days in that month with break statements for each case.
Calls getFebDays(int Year)
int getNumDays(int year, int month, int day) // returns # of days in year
Use another switch statement with no break statements to find the day of the year. 2/1 is 31 days of January plus 1 in February for a total of 32.
This must be switch with no break statements. Each month must add to the total only the days for that month. As demonstrated in class. No if or other statements on the single statement for each case that adds that month to the total.
…
case 11: retval += 30;
case 10: retval _= 31;
Calls getFebDays(int year) for case 2: retval += getFebDays(year);
Int getFebDays(int year) // returns # of days in February for this year