Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Programming in C (Windows, Not C++) #define _CRT_SECURE_NO_WARNINGS #include int daysPerMonth[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31

Programming in C (Windows, Not C++)

#define _CRT_SECURE_NO_WARNINGS

#include

int daysPerMonth[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

typedef struct date

{

int month;

int day;

int year;

} Date;

int numberOfDays(Date d);

bool isLeapYear(int year);

int main(void)

{

Date today, tomorrow;

printf("Enter today's date(mm dd yyyy): ");

scanf("%d%d%d", &today.month, &today.day, &today.year);

if (today.day != numberOfDays(today))

{

tomorrow.month = today.month;

tomorrow.day = today.day + 1;

tomorrow.year = today.year;

}

else if (today.month == 12)

{

tomorrow.month = 1;

tomorrow.day = 1;

tomorrow.year = today.year + 1;

}

else

{

tomorrow.month = today.month + 1;

tomorrow.day = 1;

tomorrow.year = today.year;

}

printf("Today's date is %d/%d/%.2d. ", today.month, today.day, today.year % 100);

printf("Tomorrow's date is %d/%d/%.2d. ", tomorrow.month, tomorrow.day, tomorrow.year % 100);

return 0;

}

int numberOfDays(Date d)

{

// Add your code here

return 30;

}

bool isLeapYear(int year)

{

// Add your code here

return false;

}

Above is a program that asks the user to enter todays date and compute tomorrows date. If you look at the programs output, you may notice that there seems to be a mistake somewhere: The day after February 28, 2012 is listed as March 1, 2012 and not as February 29, 2012. The program forgot about leap years! In this problem, write a function bool isLeapYear(int year) to determine whether a year is a leap year. Also, develop a function called int numberOfDays(Date d) to determine the number of days in a month. The function would perform the leap year test.

Hint: To determine whether a year is a leap year, follow these steps: 1. If the year is evenly divisible by 4, go to step 2. Otherwise, go to step 5. 2. If the year is evenly divisible by 100, go to step 3. Otherwise, go to step 4. 3. If the year is evenly divisible by 400, go to step 4. Otherwise, go to step 5. 4. The year is a leap year (it has 366 days). 5. The year is not a leap year (it has 365 days).

image text in transcribed

image text in transcribed

C:lUsers Izouja \Desktop DateOfTomorrow Debug Dateotf Enter today' s date(mm dd yyyy>: 10 24 2017 Today s date is 10/24/1? Tomorrow' s date is 10/25/17. C:Users\zouja\Desktop \DateOfTomorrow\Debug Date Enter today's date(mm dd yyyy>: 9 30 201? Today's date is 9/30/17. Tomorrow' s date is 10/1/17

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

Database Concepts

Authors: David Kroenke, David J. Auer

3rd Edition

0131986252, 978-0131986251

More Books

Students also viewed these Databases questions

Question

What does Processing of an OLAP Cube accomplish?

Answered: 1 week ago