Simple C,C++ Project (Program to Calculate Semester Working Days)
"Nice One Program"
#include<iostream.h>
#include<conio.h>
void main()
{ clrscr();
int start,s1,end,e1,yr,tdays;
int tdwork; //total working days
int lp=0;
char *month[]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
int days[]={31,28,31,30,31,30,31,31,30,31,30,31}; //days of mnth
cout<<"\n -->Winter Project<--\n\n";
cout<<"Enter Start and End Month\n";
for(int i=0;i<12;i++)
{
cout<<month[i]<<" As "<<i+1<<endl;
}
cout<<"Enter:";
cin>>start>>end;
{ cout<<"\nEnter Year:"; cin>>yr;
if(yr%4==0) //for leap yr check
lp=1;
}
cout<<"\nEnter Start Date of Month <"<<month[start-1]<<">:";
cin>>s1;
cout<<"\nEnter End Date of Month <"<<month[end-1]<<">:";
cin>>e1;
{
//For TOTALdays
int l1=days[start-1]-s1;
int l2=days[end-1]-e1;
tdays=l1+l2;
for(i=start;i<end-1;i++)
tdays+=days[i];
//***** TOTAL DAYS ARE HERE cout<<"totl days""<tdays; ****************
}
int tweek;
tweek=tdays/7;
//Removing All Holidays And Other days
{ tdwork=tdays-2*tweek;
int gzdays[]={4,1,1,3,1,1,1,3,1,3,3,1}; //Gazzeted Holidays Each month
//Removing leap Year
{
if(lp)
tdays++;
}
int flag=start; //bcoz of index value
//Next Lines For Start sem Month Holidays
{ if(e1>=15)
{ if(gzdays[start-1]>=2)
tdwork=tdwork-(gzdays[start-1]-1); //that 1 holidays less
}
else
tdwork=tdwork-(gzdays[start-1]);
}
//Removing holidays from Inbetween Months
while(flag<end-1) // minus 1 coz will work less than index
{
tdwork=tdwork-gzdays[flag];
flag++;
}
//Removing Holidays Of last Month
{
if(e1>=15)
{
if(gzdays[end-1]>=2)
tdwork=tdwork-(gzdays[end-1]-1);
}
else
tdwork=tdwork-(gzdays[end-1]);
}
}
if(lp) //For Leap Year
cout<<"\nTotal Days:"<<tdays<<" (Leap Year)";
else
cout<<"\nTotal Days:"<<tdays;
cout<<"\nTotal Weeks:"<<tweek;
cout<<"\n\nTotal Working Days:"<<tdwork;
cout<<"\nTotal Holidays:"<<tdays-tdwork;
cout<<"\nTotal Gazzeted Holidays:"<<(tdays-tdwork)-(2*tweek);
endl;
getch();
}
No comments:
Post a Comment