Question: Complete labdays.cpp Write a function dayNumber that returns the day number (1 to 366) in a year for a date that is provided as input
Complete labdays.cpp Write a function dayNumber that returns the day number (1 to 366) in a year for a date that is provided as input data. Your function should accept the month (1 through 12), day, and year as integers. As an example, January 1, 1994 is day 1. December 31, 1993 is day 365. December 31, 1996 is day 366 since 1996 is a leap year. A year is a leap year if its divisible by four, except that any year divisible by 100 is a leap year only if its also divisible by 400. Write and use a second function isLeapYear that returns true if its argument, a year, is a leap year. Dont modify the two function prototypes
#includeusing namespace std; /* Write a function dayNumber that returns the day number (1 to 366) in a year for a date that is provided as input data. Your function should accept the month (1 through 12), day, and year as integers. As an example, January 1, 1994 is day 1. December 31, 1993 is day 365. December 31, 1996 is day 366 since 1996 is a leap year. A year is a leap year if its divisible by four, except that any year divisible by 100 is a leap year only if its also divisible by 400. Write and use a second function isLeapYear that returns true if its argument, a year, is a leap year. */ int dayNumber(int,int,int); //Precondition: Expects three numbers. First number beween 1 and 12 (month). Second being between 1 and 31 (day). // Third being four digits (year). The three must represent a valid date. //Postcondition: The day number from 1 to 366 is returned. bool isLeapYear(int); //Precondition: Expects a four digit positive number which represents a year //Postcondition: Returns true if the given year is a leap year (year with 366 days instead of 365), false otherwise int main() { cout << "1/1/1994 is day number " << dayNumber(1,1,1994) << endl; cout << "12/31/1993 is day number " << dayNumber(12,31,1993) << endl; cout << "12/31/1996 is day number " << dayNumber(12,31,1996) << endl; cout << "7/30/2010 is day number " << dayNumber(7,30,2010) << endl; cout << "12/31/1900 is day number " << dayNumber(12,31,1900) << endl; cout << "12/31/2000 is day number " << dayNumber(12,31,2000) << endl; cout << "12/31/2010 is day number " << dayNumber(12,31,2010) << endl; return 0; }
//Define the functions here
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
