Project Help how many days are we into the year for a given date

The project ask to create a function to find how many days are into the year
int daysIntoYear ( int year, int month, int day ) ;

AND Please have your code show 12 test cases with the result from the function and the number of days into the year from internet webpage.

So far the function is working. Any help would be greatly appreciated. How would I code to show the test cases?
Typical output might look like this:

Year Month day Days Into Year Value expected Agree/Disagree

2020 1 1 1 1 agree

2020 1 20 20 20 agree

2020 3 10 70 70 agree

#include <iostream>
#include <string>


using namespace std;

//functions declaration
void homeworkHeader();
int daysIntoYear(int year, int month, int day);


int main()
{
int month;
int day;
int year;

homeworkHeader(); //call function


day = daysIntoYear(2020, 11, 1);
cout << day<< "\n";

return 0;
}

//Function
void homeworkHeader()
{
cout << "Ticket : 86720\n";
cout << "Course : CMPR 120 \n";
cout << "Vien Nguyen ( Sarah ) \n";
cout << "Instructor : Joel Kirscher\n";
cout << "Environment: Win 10 Visual Studio\n";
cout << "Project Title : Assignment 10 Vectors\n\n";
}
static char daytab[2][13] = {
{0,31,28,31,30,31,30,31,31,30,31,30,31},
{0,31,29,31,30,31,30,31,31,30,31,30,31}
};

int daysIntoYear(int year, int month, int day)
{
int i, leap;

leap = year % 4 == 0 && year % 100 != 0 || year % 400 == 0;

for (i = 1;i < month;i++)
day += daytab[leap][i];

return day;
}

.
Last edited on
Please use code tags for your code to be easier to read.
http://www.cplusplus.com/articles/jEywvCM9/
Topic archived. No new replies allowed.