Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Your program should have 4 functions. isLeapYear should be a bool value-returnin

ID: 3615316 • Letter: Y

Question

Your program should have 4 functions.

isLeapYear should be a bool value-returningfunction that determines whether the year, passed by a valueparameter is a leap year

getDate is a void function that prompts fordate input, checks that the entered date is in the correct formatand has valid numbers, passes the day month and year back usingreference parameters

dayNumber is a void function with valueparameters to pass the day month and year, and a referenceparameter to pass back the calculated day number

outputDay is a void function that outputs theoriginal date and the day number, using value parameters to passthe date and day number information

Write a program that prints the day number of the year, giventhe date in the form month-day-year. For example, if the input is1-1-2006, the day is 1; if the input is 12-25-2006 the day is 359.The program should check for a leap year. A leap year if it isdivisible by 4, but not by 100. For example, 1992 & 2008 aredivisible by 100 is a leap year if it is also divisible by 400. Forexample, 1600 and 200 are divisible by 400. However, 1800 is not aleap year because 1800 is not divisible by 400.

#include <iostream>

using namespace std;

bool isLeapYear (int year);

int main ()

{

int day, month, year;

int dayNumber;

char ch;

     cout << "Program that prints theday number: " ;

    

     cout << " Please enter a date(mm-dd-yyyy): " ;

     cin >> month;

     cin >> day ;

     cin >> year;

     cin >> ch ;   

dayNumber = 0;

while (month > 1)

{

      // all numbers come after

switch (month 1)

{

       

         case 2:

            dayNumber = 28;

            

        if (isLeapYear (year))

          dayNumber++;

          break;

          

        case 4:

        case 6:

        case 9:

        case 11:

            dayNumber = 30;

            break;

       

          case 1 :

        case 3 :

        case 5 :

        case 7 :

        case 8 :

        case 10:

        case 12:

            

            dayNumber = 31;

            break;

            

     

      

}

month--;

}

dayNumber = day;

          cout<< "The day number is: " << dayNumber;

         

         system("PAUSE");

          return0;

         

          }

         

bool isLeapYear (int year)

{

    

     if (isLeapYear / =4) &&(isLeapYear !/ = 100) ||

    

   (isLeapYear / =100 ) && (isLeapYear / =400)

    

     return true;

    

     return false;

    

    }

Explanation / Answer

//Hope this will helpyou.

#include<stdio.h> #include<iostream> using namespace std; int isLeapYear(int yr) {    if( ((yr %4==0) && (yr%100 !=0 )) ||(yr%400 ==0))    {       return 1;    }    else    {          return 0;    } } void dayNumber (int d,int m,int y,int &dnum) { int i;    intmm[12]={31,28,31,30,31,30,31,31,30,31,30,31};    if(isLeapYear(y))    {    mm[1]=29;    }    dnum=0;    for(i=0;i<m-1;i++)    {    dnum += mm[i];    }    dnum += d;       } void getDate (int &d, int &m,int &y) {
printf("Enter date:mm -"); scanf("%d",&m); printf("Enter date:dd -"); scanf("%d",&d); printf("Enter date:yyyy -"); scanf("%d",&y);
}
void outputDay (int d,int m,int y,int dnum) {    cout<<m<<"-"<<d<<"-"<<y<<" : The day is :"<<dnum<<endl; } int main(){ int d,m,y,dnum; getDate(d,m,y); dayNumber(d,m,y,dnum); outputDay(d,m,y,dnum); system("pause"); }