Help!!!!!!!!!!!!!!

Can someone help? I did write up a code, but my teacher doesnt like the way I went about the program because I did not use the proper headers. Does anyonone know how to write the code with these headers?
These must be the headers:

bool isLeapYear(int y)
int countDays(int m, int d, bool leap)

Your program logic should work as follows. Request a date from the user. Parse the date string into month, day, and year. Validate all input, that is, if the user enters 13 for the month, you should trap that error and provide a suitable error message to the user.

After all validations, you need to call isLeapYear to know whether to count 28 or 29 days for February then you invoke countDays to add up all the days between January 1st and the date the user entered, inclusive.

Here is a screenshot of the way the code should be running:



Enter Date using this format mm-dd-yyy: 03-01-2000

March 1 is day 61 in the year 2000.


Here is the code I had:
#include <cstdlib>
#include <iostream>

using namespace std;

int countDays(int , int , int, int);

int main(int argc, char *argv[])
{

int m, d, y, td;
char d1, d2;

cout<<"***Day Of Year***\n"<<endl;
cout<<"Returns the number of days in the"<<endl;
cout<<"year for the date entered.\n"<<endl;

cout<<"Enter a Date using the format(mm-dd-yyyy): ";
cin>>m>>d1>>d>>d2>>y;

td= countDays (m,d,y,td);

cout<<"Total Days in the year Passed: "<<td<<endl;

system("PAUSE");
return EXIT_SUCCESS;
}
int countDays(int m, int d, int y, int td)
{
switch(m)
{
case 1: td=d;
break;
case 2: td=d+31;
break;
case 3: td=d+59;
break;
case 4: td=d+90;
break;
case 5: td=d+120;
break;
case 6: td=d+151;
break;
case 7: td=d+181;
break;
case 8: td=d+212;
break;
case 9: td=d+243;
break;
case 10: td=d+273;
break;
case 11: td=d+304;
break;
case 12: td=d+334;
break;

default: td=0;
break;
}

if(m>2 && 0==y%4)
++td;

return td;
}

Last edited on
Topic archived. No new replies allowed.