SlideShare a Scribd company logo
1 of 47
Download to read offline
Please make a comment for all the codes
Or explain this program code!!
//Date.h
#ifndef DateFormat
#define DateFormat
#include
using std::string;
class Date {
public:
Date();
Date( int, int );
Date( int, int, int );
Date( string, int, int );
void setDay11(int);
void setMonth11( int );
void print11() const;
void printDDDYYYY11( ) const;
void printMMDDYY11( ) const;
void printMonthDDYYYY11( ) const;
~Date();
private:
int month1;
int day1;
int year1;
int checkDay(int)const;
int daysInMonth(int)const;
bool isLeapYear()const;
int convertDDToDDD()const;
void setMMDDFromDDD(int);
string convertMMToMonth(int)const;
void setMMFromMonth(string);
int convertYYYYToYY()const;
void setYYYYFromYY(int);
};
#endif
//Main.cpp
include
using std::cout;
using std::endl;
#include "Date.h"
int main()
{
Date date1( 252,1999 );
Date date2( 2,25,04 );
Date date3( "September", 1, 2000 );
Date date4;
date1.print11();
date2.print11();
date3.print11();
date4.print11();
cout << ' ';
date1.printDDDYYYY11();
date2.printDDDYYYY11();
date3.printDDDYYYY11();
date4.printDDDYYYY11();
cout << ' ';
date1.printMMDDYY11();
date2.printMMDDYY11();
date3.printMMDDYY11();
date4.printMMDDYY11();
cout << endl;
date1.printMonthDDYYYY11();
date2.printMonthDDYYYY11();
date3.printMonthDDYYYY11();
date4.printMonthDDYYYY11();
return 0;
}
//Date.cpp
#include
using std::cout;
using std::endl;
#include
using std::setw;
using std::setfill;
include
using std::time;
using std::localtime;
using std::tm;
using std::time_t;
#include "Date.h"
Date::Date()
{
struct tm *ptr;
time_t t1 = time( 0 );
ptr = localtime( &t1 );
day1 = ptr->tm_mday;
month1 = 1 + ptr->tm_mon;
year1 = ptr->tm_year + 1900;
}
Date::Date( int ddd1, int yyyy1 )
{
year1=yyyy1;
setMMDDFromDDD(ddd1);
}
Date::Date( int mm1, int dd1, int yy1 )
{
setYYYYFromYY( yy1 );
mm1 );
setDay11( dd1 );
}
Date::Date(string monthName2,int dd1,int yyyy1)
{
setMMFromMonth(monthName2);
setDay11(dd1);
year1=yyyy1;
}
void Date::setDay11( int d1 )
{
day1 = checkDay(d1); }
void Date::setMonth11( int m1 )
{
if(m1>0&& m1<=12)
month1=m1;
else
{
month1=1;
cout<<"invalid month("<0 && testDay<=daysInMonth(month1))
return testDay;
if(month1==2 && testDay==29 && isLeapYear())
return testDay;
cout<<"invalid day("<=2000?year1-2000:year1-1900);
}
void Date::setYYYYFromYY(int yy)
{
year1=(yy<7?yy+2000:yy+1900);
}
Please make a comment for all the codes
Or explain this program code!!
//Date.h
#ifndef DateFormat
#define DateFormat
#include
using std::string;
class Date {
public:
Date();
Date( int, int );
Date( int, int, int );
Date( string, int, int );
void setDay11(int);
void setMonth11( int );
void print11() const;
void printDDDYYYY11( ) const;
void printMMDDYY11( ) const;
void printMonthDDYYYY11( ) const;
~Date();
private:
int month1;
int day1;
int year1;
int checkDay(int)const;
int daysInMonth(int)const;
bool isLeapYear()const;
int convertDDToDDD()const;
void setMMDDFromDDD(int);
string convertMMToMonth(int)const;
void setMMFromMonth(string);
int convertYYYYToYY()const;
void setYYYYFromYY(int);
};
#endif
//Main.cpp
include
using std::cout;
using std::endl;
#include "Date.h"
int main()
{
Date date1( 252,1999 );
Date date2( 2,25,04 );
Date date3( "September", 1, 2000 );
Date date4;
date1.print11();
date2.print11();
date3.print11();
date4.print11();
cout << ' ';
date1.printDDDYYYY11();
date2.printDDDYYYY11();
date3.printDDDYYYY11();
date4.printDDDYYYY11();
cout << ' ';
date1.printMMDDYY11();
date2.printMMDDYY11();
date3.printMMDDYY11();
date4.printMMDDYY11();
cout << endl;
date1.printMonthDDYYYY11();
date2.printMonthDDYYYY11();
date3.printMonthDDYYYY11();
date4.printMonthDDYYYY11();
return 0;
}
//Date.cpp
#include
using std::cout;
using std::endl;
#include
using std::setw;
using std::setfill;
include
using std::time;
using std::localtime;
using std::tm;
using std::time_t;
#include "Date.h"
Date::Date()
{
struct tm *ptr;
time_t t1 = time( 0 );
ptr = localtime( &t1 );
day1 = ptr->tm_mday;
month1 = 1 + ptr->tm_mon;
year1 = ptr->tm_year + 1900;
}
Date::Date( int ddd1, int yyyy1 )
{
year1=yyyy1;
setMMDDFromDDD(ddd1);
}
Date::Date( int mm1, int dd1, int yy1 )
{
setYYYYFromYY( yy1 );
mm1 );
setDay11( dd1 );
}
Date::Date(string monthName2,int dd1,int yyyy1)
{
setMMFromMonth(monthName2);
setDay11(dd1);
year1=yyyy1;
}
void Date::setDay11( int d1 )
{
day1 = checkDay(d1); }
void Date::setMonth11( int m1 )
{
if(m1>0&& m1<=12)
month1=m1;
else
{
month1=1;
cout<<"invalid month("<0 && testDay<=daysInMonth(month1))
return testDay;
if(month1==2 && testDay==29 && isLeapYear())
return testDay;
cout<<"invalid day("<=2000?year1-2000:year1-1900);
}
void Date::setYYYYFromYY(int yy)
{
year1=(yy<7?yy+2000:yy+1900);
}
Please make a comment for all the codes
Or explain this program code!!
//Date.h
#ifndef DateFormat
#define DateFormat
#include
using std::string;
class Date {
public:
Date();
Date( int, int );
Date( int, int, int );
Date( string, int, int );
void setDay11(int);
void setMonth11( int );
void print11() const;
void printDDDYYYY11( ) const;
void printMMDDYY11( ) const;
void printMonthDDYYYY11( ) const;
~Date();
private:
int month1;
int day1;
int year1;
int checkDay(int)const;
int daysInMonth(int)const;
bool isLeapYear()const;
int convertDDToDDD()const;
void setMMDDFromDDD(int);
string convertMMToMonth(int)const;
void setMMFromMonth(string);
int convertYYYYToYY()const;
void setYYYYFromYY(int);
};
#endif
//Main.cpp
include
using std::cout;
using std::endl;
#include "Date.h"
int main()
{
Date date1( 252,1999 );
Date date2( 2,25,04 );
Date date3( "September", 1, 2000 );
Date date4;
date1.print11();
date2.print11();
date3.print11();
date4.print11();
cout << ' ';
date1.printDDDYYYY11();
date2.printDDDYYYY11();
date3.printDDDYYYY11();
date4.printDDDYYYY11();
cout << ' ';
date1.printMMDDYY11();
date2.printMMDDYY11();
date3.printMMDDYY11();
date4.printMMDDYY11();
cout << endl;
date1.printMonthDDYYYY11();
date2.printMonthDDYYYY11();
date3.printMonthDDYYYY11();
date4.printMonthDDYYYY11();
return 0;
}
//Date.cpp
#include
using std::cout;
using std::endl;
#include
using std::setw;
using std::setfill;
include
using std::time;
using std::localtime;
using std::tm;
using std::time_t;
#include "Date.h"
Date::Date()
{
struct tm *ptr;
time_t t1 = time( 0 );
ptr = localtime( &t1 );
day1 = ptr->tm_mday;
month1 = 1 + ptr->tm_mon;
year1 = ptr->tm_year + 1900;
}
Date::Date( int ddd1, int yyyy1 )
{
year1=yyyy1;
setMMDDFromDDD(ddd1);
}
Date::Date( int mm1, int dd1, int yy1 )
{
setYYYYFromYY( yy1 );
include
using std::cout;
using std::endl;
#include "Date.h"
int main()
{
Date date1( 252,1999 );
Date date2( 2,25,04 );
Date date3( "September", 1, 2000 );
Date date4;
date1.print11();
date2.print11();
date3.print11();
date4.print11();
cout << ' ';
date1.printDDDYYYY11();
date2.printDDDYYYY11();
date3.printDDDYYYY11();
date4.printDDDYYYY11();
cout << ' ';
date1.printMMDDYY11();
date2.printMMDDYY11();
date3.printMMDDYY11();
date4.printMMDDYY11();
cout << endl;
date1.printMonthDDYYYY11();
date2.printMonthDDYYYY11();
date3.printMonthDDYYYY11();
date4.printMonthDDYYYY11();
return 0;
}
//Date.cpp
#include
using std::cout;
using std::endl;
#include
using std::setw;
using std::setfill;
include
using std::time;
using std::localtime;
using std::tm;
using std::time_t;
#include "Date.h"
Date::Date()
{
struct tm *ptr;
time_t t1 = time( 0 );
ptr = localtime( &t1 );
day1 = ptr->tm_mday;
month1 = 1 + ptr->tm_mon;
year1 = ptr->tm_year + 1900;
}
Date::Date( int ddd1, int yyyy1 )
{
year1=yyyy1;
setMMDDFromDDD(ddd1);
}
Date::Date( int mm1, int dd1, int yy1 )
{
setYYYYFromYY( yy1 );
include
using std::time;
using std::localtime;
using std::tm;
using std::time_t;
#include "Date.h"
Date::Date()
{
struct tm *ptr;
time_t t1 = time( 0 );
ptr = localtime( &t1 );
day1 = ptr->tm_mday;
month1 = 1 + ptr->tm_mon;
year1 = ptr->tm_year + 1900;
}
Date::Date( int ddd1, int yyyy1 )
{
year1=yyyy1;
setMMDDFromDDD(ddd1);
}
Date::Date( int mm1, int dd1, int yy1 )
{
setYYYYFromYY( yy1 );
mm1 );
setDay11( dd1 );
}
Date::Date(string monthName2,int dd1,int yyyy1)
{
setMMFromMonth(monthName2);
setDay11(dd1);
year1=yyyy1;
}
void Date::setDay11( int d1 )
{
day1 = checkDay(d1); }
void Date::setMonth11( int m1 )
{
if(m1>0&& m1<=12)
month1=m1;
else
{
month1=1;
cout<<"invalid month("<0&& m1<=12)
month1=m1;
else
{
month1=1;
cout<<"invalid month("<0 && testDay<=daysInMonth(month1))
return testDay;
if(month1==2 && testDay==29 && isLeapYear())
return testDay;
cout<<"invalid day("<0 && testDay<=daysInMonth(month1))
return testDay;
if(month1==2 && testDay==29 && isLeapYear())
return testDay;
cout<<"invalid day("<=2000?year1-2000:year1-1900);
}
void Date::setYYYYFromYY(int yy)
{
year1=(yy<7?yy+2000:yy+1900);
}
{
static const string months1[]={"
","January","February","March","April","May","June","July","August","September
","October","November","december"};
return months1[mm];
}
void Date::setMMFromMonth(string m1)
{
bool matchFound=false;
for(int k=1;k<=12&&!matchFound;k++)
{
string tempMonth1=convertMMToMonth(k);
if(tempMonth1==m1)
{
setMonth11(k);
matchFound=true;
}
}
if(!matchFound)
{
cout<<"invalid month name("<=2000?year1-2000:year1-1900);
}
void Date::setYYYYFromYY(int yy)
{
year1=(yy<7?yy+2000:yy+1900);
}
Solution
//Date.h
#ifndef DateFormat
#define DateFormat
#include
using std::string;
class Date {
public:
// constructor
Date();
// parameterized consturctors
Date( int, int );
Date( int, int, int );
Date( string, int, int );
// setters
void setDay11(int);
void setMonth11( int );
// print functions
void print11() const;
void printDDDYYYY11( ) const;
void printMMDDYY11( ) const;
void printMonthDDYYYY11( ) const;
~Date();
private:
// variables
int month1;
int day1;
int year1;
// check valid day
int checkDay(int)const;
// count days in month
int daysInMonth(int)const;
// check leap year
bool isLeapYear()const;
// converter function
int convertDDToDDD()const;
// setter
void setMMDDFromDDD(int);
// converter function
string convertMMToMonth(int)const;
// setter
void setMMFromMonth(string);
// converter function
int convertYYYYToYY()const;
// setter
void setYYYYFromYY(int);
};
#endif
//Date.cpp
// input output library
#include
using std::cout;
using std::endl;
// library to set width and fill
#include
using std::setw;
using std::setfill;
// library to use time
#include
using std::time;
using std::localtime;
using std::tm;
using std::time_t;
#include "Date.h"
// default constructor
Date::Date()
{
// taking pointer to tm
struct tm *ptr;
// set time as 0
time_t t1 = time( 0 );
// pointer taking address of t1
ptr = localtime( &t1 );
// day1 holds the day value of ptr
day1 = ptr->tm_mday;
// month1 holds the month value of ptr
month1 = 1 + ptr->tm_mon;
// year1 holds the year value of ptr + 1900
year1 = ptr->tm_year + 1900;
}
// parameterized constructor
Date::Date( int ddd1, int yyyy1 )
{
// set year
year1=yyyy1;
// call the month from date function
setMMDDFromDDD(ddd1);
}
// parameterized constructor
Date::Date( int mm1, int dd1, int yy1 )
{
// call the year from year function
setYYYYFromYY( yy1 );
// set day function
setDay11( dd1 );
}
// parameterized constructor
Date::Date(string monthName2,int dd1,int yyyy1)
{
// call the month from month function
setMMFromMonth(monthName2);
// setday
setDay11(dd1);
year1=yyyy1;
}
void Date::setDay11( int d1 )
{
// check for valid day and set it
day1 = checkDay(d1);
}
void Date::setMonth11( int m1 )
{
// check for valid month and set it
if(m1>0&& m1<=12)
month1=m1;
else
{
// end set month to 1
month1=1;
cout<<"invalid month("<0 && testDay<=daysInMonth(month1))
return testDay;
if(month1==2 && testDay==29 && isLeapYear())
return testDay;
cout<<"invalid day("<=2000?year1-2000:year1-1900);
}
// other yer converter function
void Date::setYYYYFromYY(int yy)
{
year1=(yy<7?yy+2000:yy+1900);
}
//Main.cpp
// input output library
#include
using std::cout;
using std::endl;
#include "Date.h"
int main()
{
// calling parameterized constructors
Date date1( 252,1999 );
Date date2( 2,25,04 );
Date date3( "September", 1, 2000 );
// print dates
Date date4;
date1.print11();
date2.print11();
date3.print11();
date4.print11();
// print date to years
cout << ' ';
date1.printDDDYYYY11();
date2.printDDDYYYY11();
date3.printDDDYYYY11();
date4.printDDDYYYY11();
// print month to date to years
cout << ' ';
date1.printMMDDYY11();
date2.printMMDDYY11();
date3.printMMDDYY11();
date4.printMMDDYY11();
// print final dates
cout << endl;
date1.printMonthDDYYYY11();
date2.printMonthDDYYYY11();
date3.printMonthDDYYYY11();
date4.printMonthDDYYYY11();
return 0;
}
/*
output:
invalid day(193)set to 1
3/1/1999
3/25/2004
9/1/2000
10/11/2016
60 1999
85 2004
245 2000
285 2016
03/0199
03/2504
09/0100
10/1116
March 1,1999
March 25,2004
September 1,2000
October 11,2016
date object destructor for date10/11/2016
date object destructor for date9/1/2000
date object destructor for date3/25/2004
date object destructor for date3/1/1999
*/

More Related Content

Similar to Please make a comment for all the codesOr explain this pro.pdf

package reservation; import java.util.; For Scanner Class .pdf
 package reservation; import java.util.; For Scanner Class .pdf package reservation; import java.util.; For Scanner Class .pdf
package reservation; import java.util.; For Scanner Class .pdfanitasahani11
 
DeVry GSP 115 All Assignments latest
DeVry GSP 115 All Assignments latestDeVry GSP 115 All Assignments latest
DeVry GSP 115 All Assignments latestAtifkhilji
 
c++ project on restaurant billing
c++ project on restaurant billing c++ project on restaurant billing
c++ project on restaurant billing Swakriti Rathore
 
All I know about rsc.io/c2go
All I know about rsc.io/c2goAll I know about rsc.io/c2go
All I know about rsc.io/c2goMoriyoshi Koizumi
 
Distributed Computing Patterns in R
Distributed Computing Patterns in RDistributed Computing Patterns in R
Distributed Computing Patterns in Rarmstrtw
 
Creating an Uber Clone - Part III.pdf
Creating an Uber Clone - Part III.pdfCreating an Uber Clone - Part III.pdf
Creating an Uber Clone - Part III.pdfShaiAlmog1
 
Bcsl 033 data and file structures lab s5-2
Bcsl 033 data and file structures lab s5-2Bcsl 033 data and file structures lab s5-2
Bcsl 033 data and file structures lab s5-2Dr. Loganathan R
 
Date.h#ifndef DateFormat#define DateFormat#includetime.h.pdf
Date.h#ifndef DateFormat#define DateFormat#includetime.h.pdfDate.h#ifndef DateFormat#define DateFormat#includetime.h.pdf
Date.h#ifndef DateFormat#define DateFormat#includetime.h.pdfangelfragranc
 
Final Project SkeletonCipherClient.javaFinal Project SkeletonC.docx
Final Project SkeletonCipherClient.javaFinal Project SkeletonC.docxFinal Project SkeletonCipherClient.javaFinal Project SkeletonC.docx
Final Project SkeletonCipherClient.javaFinal Project SkeletonC.docxvoversbyobersby
 
GDSC Flutter Forward Workshop.pptx
GDSC Flutter Forward Workshop.pptxGDSC Flutter Forward Workshop.pptx
GDSC Flutter Forward Workshop.pptxGDSCVJTI
 

Similar to Please make a comment for all the codesOr explain this pro.pdf (12)

package reservation; import java.util.; For Scanner Class .pdf
 package reservation; import java.util.; For Scanner Class .pdf package reservation; import java.util.; For Scanner Class .pdf
package reservation; import java.util.; For Scanner Class .pdf
 
DeVry GSP 115 All Assignments latest
DeVry GSP 115 All Assignments latestDeVry GSP 115 All Assignments latest
DeVry GSP 115 All Assignments latest
 
c++ project on restaurant billing
c++ project on restaurant billing c++ project on restaurant billing
c++ project on restaurant billing
 
Drawing Figures
Drawing FiguresDrawing Figures
Drawing Figures
 
Functions
FunctionsFunctions
Functions
 
All I know about rsc.io/c2go
All I know about rsc.io/c2goAll I know about rsc.io/c2go
All I know about rsc.io/c2go
 
Distributed Computing Patterns in R
Distributed Computing Patterns in RDistributed Computing Patterns in R
Distributed Computing Patterns in R
 
Creating an Uber Clone - Part III.pdf
Creating an Uber Clone - Part III.pdfCreating an Uber Clone - Part III.pdf
Creating an Uber Clone - Part III.pdf
 
Bcsl 033 data and file structures lab s5-2
Bcsl 033 data and file structures lab s5-2Bcsl 033 data and file structures lab s5-2
Bcsl 033 data and file structures lab s5-2
 
Date.h#ifndef DateFormat#define DateFormat#includetime.h.pdf
Date.h#ifndef DateFormat#define DateFormat#includetime.h.pdfDate.h#ifndef DateFormat#define DateFormat#includetime.h.pdf
Date.h#ifndef DateFormat#define DateFormat#includetime.h.pdf
 
Final Project SkeletonCipherClient.javaFinal Project SkeletonC.docx
Final Project SkeletonCipherClient.javaFinal Project SkeletonC.docxFinal Project SkeletonCipherClient.javaFinal Project SkeletonC.docx
Final Project SkeletonCipherClient.javaFinal Project SkeletonC.docx
 
GDSC Flutter Forward Workshop.pptx
GDSC Flutter Forward Workshop.pptxGDSC Flutter Forward Workshop.pptx
GDSC Flutter Forward Workshop.pptx
 

More from arihantcommunication

C++Write a function bool isLevel(int a, int n) which determines i.pdf
C++Write a function bool isLevel(int a, int n) which determines i.pdfC++Write a function bool isLevel(int a, int n) which determines i.pdf
C++Write a function bool isLevel(int a, int n) which determines i.pdfarihantcommunication
 
Arsenic is implanted into a lightly doped p-type Si substrate at an e.pdf
Arsenic is implanted into a lightly doped p-type Si substrate at an e.pdfArsenic is implanted into a lightly doped p-type Si substrate at an e.pdf
Arsenic is implanted into a lightly doped p-type Si substrate at an e.pdfarihantcommunication
 
According to Mendels Law of Segregation which of the following is s.pdf
According to Mendels Law of Segregation which of the following is s.pdfAccording to Mendels Law of Segregation which of the following is s.pdf
According to Mendels Law of Segregation which of the following is s.pdfarihantcommunication
 
A concerned mother brings her 2-year-old daughter to the clinic with.pdf
A concerned mother brings her 2-year-old daughter to the clinic with.pdfA concerned mother brings her 2-year-old daughter to the clinic with.pdf
A concerned mother brings her 2-year-old daughter to the clinic with.pdfarihantcommunication
 
A study compared 4 groups with 6 observations per group. An statisti.pdf
A study compared 4 groups with 6 observations per group. An statisti.pdfA study compared 4 groups with 6 observations per group. An statisti.pdf
A study compared 4 groups with 6 observations per group. An statisti.pdfarihantcommunication
 
Why is it important that chromosomes can cross over in Meiosis and n.pdf
Why is it important that chromosomes can cross over in Meiosis and n.pdfWhy is it important that chromosomes can cross over in Meiosis and n.pdf
Why is it important that chromosomes can cross over in Meiosis and n.pdfarihantcommunication
 
Write a one-page statement showing that you have A knowledge of cur.pdf
Write a one-page statement showing that you have A knowledge of cur.pdfWrite a one-page statement showing that you have A knowledge of cur.pdf
Write a one-page statement showing that you have A knowledge of cur.pdfarihantcommunication
 
Which of the following is the purpose of valves in the venous circul.pdf
Which of the following is the purpose of valves in the venous circul.pdfWhich of the following is the purpose of valves in the venous circul.pdf
Which of the following is the purpose of valves in the venous circul.pdfarihantcommunication
 
When society makes a particular good or service illegal is it making.pdf
When society makes a particular good or service illegal is it making.pdfWhen society makes a particular good or service illegal is it making.pdf
When society makes a particular good or service illegal is it making.pdfarihantcommunication
 
Which physical topology has all systems connecting to a central conn.pdf
Which physical topology has all systems connecting to a central conn.pdfWhich physical topology has all systems connecting to a central conn.pdf
Which physical topology has all systems connecting to a central conn.pdfarihantcommunication
 
What is the role of RFID chips in logistics What is the role o.pdf
What is the role of RFID chips in logistics What is the role o.pdfWhat is the role of RFID chips in logistics What is the role o.pdf
What is the role of RFID chips in logistics What is the role o.pdfarihantcommunication
 
tut all words or phases will be inca. cach likathawnb tha bat wer.pdf
tut all words or phases will be inca. cach likathawnb tha bat wer.pdftut all words or phases will be inca. cach likathawnb tha bat wer.pdf
tut all words or phases will be inca. cach likathawnb tha bat wer.pdfarihantcommunication
 
Theories of law enforcementSubjectDiscuss the positive and negati.pdf
Theories of law enforcementSubjectDiscuss the positive and negati.pdfTheories of law enforcementSubjectDiscuss the positive and negati.pdf
Theories of law enforcementSubjectDiscuss the positive and negati.pdfarihantcommunication
 
What does a blower door doSolutionA blower door is a device w.pdf
What does a blower door doSolutionA blower door is a device w.pdfWhat does a blower door doSolutionA blower door is a device w.pdf
What does a blower door doSolutionA blower door is a device w.pdfarihantcommunication
 
The US population in millions is P(t) today, where time t is measured.pdf
The US population in millions is P(t) today, where time t is measured.pdfThe US population in millions is P(t) today, where time t is measured.pdf
The US population in millions is P(t) today, where time t is measured.pdfarihantcommunication
 
The purpose of a database is to. Select one store lists of data invo.pdf
The purpose of a database is to. Select one store lists of data invo.pdfThe purpose of a database is to. Select one store lists of data invo.pdf
The purpose of a database is to. Select one store lists of data invo.pdfarihantcommunication
 
Stadents version-p. 2 0. (Table 3) item(s) at the deli bar causing .pdf
Stadents version-p. 2 0. (Table 3) item(s) at the deli bar causing .pdfStadents version-p. 2 0. (Table 3) item(s) at the deli bar causing .pdf
Stadents version-p. 2 0. (Table 3) item(s) at the deli bar causing .pdfarihantcommunication
 
A major hurricane is a hurricane with wind speeds of 111 miles per h.pdf
A major hurricane is a hurricane with wind speeds of 111 miles per h.pdfA major hurricane is a hurricane with wind speeds of 111 miles per h.pdf
A major hurricane is a hurricane with wind speeds of 111 miles per h.pdfarihantcommunication
 
1.In which case(s) is there constructive interference for two ligh.pdf
1.In which case(s) is there constructive interference for two ligh.pdf1.In which case(s) is there constructive interference for two ligh.pdf
1.In which case(s) is there constructive interference for two ligh.pdfarihantcommunication
 
List and describe three examples of secondary sexual characteristics.pdf
List and describe three examples of secondary sexual characteristics.pdfList and describe three examples of secondary sexual characteristics.pdf
List and describe three examples of secondary sexual characteristics.pdfarihantcommunication
 

More from arihantcommunication (20)

C++Write a function bool isLevel(int a, int n) which determines i.pdf
C++Write a function bool isLevel(int a, int n) which determines i.pdfC++Write a function bool isLevel(int a, int n) which determines i.pdf
C++Write a function bool isLevel(int a, int n) which determines i.pdf
 
Arsenic is implanted into a lightly doped p-type Si substrate at an e.pdf
Arsenic is implanted into a lightly doped p-type Si substrate at an e.pdfArsenic is implanted into a lightly doped p-type Si substrate at an e.pdf
Arsenic is implanted into a lightly doped p-type Si substrate at an e.pdf
 
According to Mendels Law of Segregation which of the following is s.pdf
According to Mendels Law of Segregation which of the following is s.pdfAccording to Mendels Law of Segregation which of the following is s.pdf
According to Mendels Law of Segregation which of the following is s.pdf
 
A concerned mother brings her 2-year-old daughter to the clinic with.pdf
A concerned mother brings her 2-year-old daughter to the clinic with.pdfA concerned mother brings her 2-year-old daughter to the clinic with.pdf
A concerned mother brings her 2-year-old daughter to the clinic with.pdf
 
A study compared 4 groups with 6 observations per group. An statisti.pdf
A study compared 4 groups with 6 observations per group. An statisti.pdfA study compared 4 groups with 6 observations per group. An statisti.pdf
A study compared 4 groups with 6 observations per group. An statisti.pdf
 
Why is it important that chromosomes can cross over in Meiosis and n.pdf
Why is it important that chromosomes can cross over in Meiosis and n.pdfWhy is it important that chromosomes can cross over in Meiosis and n.pdf
Why is it important that chromosomes can cross over in Meiosis and n.pdf
 
Write a one-page statement showing that you have A knowledge of cur.pdf
Write a one-page statement showing that you have A knowledge of cur.pdfWrite a one-page statement showing that you have A knowledge of cur.pdf
Write a one-page statement showing that you have A knowledge of cur.pdf
 
Which of the following is the purpose of valves in the venous circul.pdf
Which of the following is the purpose of valves in the venous circul.pdfWhich of the following is the purpose of valves in the venous circul.pdf
Which of the following is the purpose of valves in the venous circul.pdf
 
When society makes a particular good or service illegal is it making.pdf
When society makes a particular good or service illegal is it making.pdfWhen society makes a particular good or service illegal is it making.pdf
When society makes a particular good or service illegal is it making.pdf
 
Which physical topology has all systems connecting to a central conn.pdf
Which physical topology has all systems connecting to a central conn.pdfWhich physical topology has all systems connecting to a central conn.pdf
Which physical topology has all systems connecting to a central conn.pdf
 
What is the role of RFID chips in logistics What is the role o.pdf
What is the role of RFID chips in logistics What is the role o.pdfWhat is the role of RFID chips in logistics What is the role o.pdf
What is the role of RFID chips in logistics What is the role o.pdf
 
tut all words or phases will be inca. cach likathawnb tha bat wer.pdf
tut all words or phases will be inca. cach likathawnb tha bat wer.pdftut all words or phases will be inca. cach likathawnb tha bat wer.pdf
tut all words or phases will be inca. cach likathawnb tha bat wer.pdf
 
Theories of law enforcementSubjectDiscuss the positive and negati.pdf
Theories of law enforcementSubjectDiscuss the positive and negati.pdfTheories of law enforcementSubjectDiscuss the positive and negati.pdf
Theories of law enforcementSubjectDiscuss the positive and negati.pdf
 
What does a blower door doSolutionA blower door is a device w.pdf
What does a blower door doSolutionA blower door is a device w.pdfWhat does a blower door doSolutionA blower door is a device w.pdf
What does a blower door doSolutionA blower door is a device w.pdf
 
The US population in millions is P(t) today, where time t is measured.pdf
The US population in millions is P(t) today, where time t is measured.pdfThe US population in millions is P(t) today, where time t is measured.pdf
The US population in millions is P(t) today, where time t is measured.pdf
 
The purpose of a database is to. Select one store lists of data invo.pdf
The purpose of a database is to. Select one store lists of data invo.pdfThe purpose of a database is to. Select one store lists of data invo.pdf
The purpose of a database is to. Select one store lists of data invo.pdf
 
Stadents version-p. 2 0. (Table 3) item(s) at the deli bar causing .pdf
Stadents version-p. 2 0. (Table 3) item(s) at the deli bar causing .pdfStadents version-p. 2 0. (Table 3) item(s) at the deli bar causing .pdf
Stadents version-p. 2 0. (Table 3) item(s) at the deli bar causing .pdf
 
A major hurricane is a hurricane with wind speeds of 111 miles per h.pdf
A major hurricane is a hurricane with wind speeds of 111 miles per h.pdfA major hurricane is a hurricane with wind speeds of 111 miles per h.pdf
A major hurricane is a hurricane with wind speeds of 111 miles per h.pdf
 
1.In which case(s) is there constructive interference for two ligh.pdf
1.In which case(s) is there constructive interference for two ligh.pdf1.In which case(s) is there constructive interference for two ligh.pdf
1.In which case(s) is there constructive interference for two ligh.pdf
 
List and describe three examples of secondary sexual characteristics.pdf
List and describe three examples of secondary sexual characteristics.pdfList and describe three examples of secondary sexual characteristics.pdf
List and describe three examples of secondary sexual characteristics.pdf
 

Recently uploaded

REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptNishitharanjan Rout
 
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfUGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfNirmal Dwivedi
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111GangaMaiya1
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxAdelaideRefugio
 
Introduction to TechSoup’s Digital Marketing Services and Use Cases
Introduction to TechSoup’s Digital Marketing  Services and Use CasesIntroduction to TechSoup’s Digital Marketing  Services and Use Cases
Introduction to TechSoup’s Digital Marketing Services and Use CasesTechSoup
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code ExamplesPeter Brusilovsky
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...EduSkills OECD
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptxJoelynRubio1
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonhttgc7rh9c
 
Orientation Canvas Course Presentation.pdf
Orientation Canvas Course Presentation.pdfOrientation Canvas Course Presentation.pdf
Orientation Canvas Course Presentation.pdfElizabeth Walsh
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsNbelano25
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and ModificationsMJDuyan
 
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdfDiuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdfKartik Tiwari
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsSandeep D Chaudhary
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxmarlenawright1
 

Recently uploaded (20)

REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
AIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.pptAIM of Education-Teachers Training-2024.ppt
AIM of Education-Teachers Training-2024.ppt
 
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdfUGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
UGC NET Paper 1 Unit 7 DATA INTERPRETATION.pdf
 
Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111Details on CBSE Compartment Exam.pptx1111
Details on CBSE Compartment Exam.pptx1111
 
Observing-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptxObserving-Correct-Grammar-in-Making-Definitions.pptx
Observing-Correct-Grammar-in-Making-Definitions.pptx
 
Introduction to TechSoup’s Digital Marketing Services and Use Cases
Introduction to TechSoup’s Digital Marketing  Services and Use CasesIntroduction to TechSoup’s Digital Marketing  Services and Use Cases
Introduction to TechSoup’s Digital Marketing Services and Use Cases
 
SPLICE Working Group: Reusable Code Examples
SPLICE Working Group:Reusable Code ExamplesSPLICE Working Group:Reusable Code Examples
SPLICE Working Group: Reusable Code Examples
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx21st_Century_Skills_Framework_Final_Presentation_2.pptx
21st_Century_Skills_Framework_Final_Presentation_2.pptx
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lessonQUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
QUATER-1-PE-HEALTH-LC2- this is just a sample of unpacked lesson
 
Including Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdfIncluding Mental Health Support in Project Delivery, 14 May.pdf
Including Mental Health Support in Project Delivery, 14 May.pdf
 
Orientation Canvas Course Presentation.pdf
Orientation Canvas Course Presentation.pdfOrientation Canvas Course Presentation.pdf
Orientation Canvas Course Presentation.pdf
 
Tatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf artsTatlong Kwento ni Lola basyang-1.pdf arts
Tatlong Kwento ni Lola basyang-1.pdf arts
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdfDiuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
Diuretic, Hypoglycemic and Limit test of Heavy metals and Arsenic.-1.pdf
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 

Please make a comment for all the codesOr explain this pro.pdf

  • 1. Please make a comment for all the codes Or explain this program code!! //Date.h #ifndef DateFormat #define DateFormat #include using std::string; class Date { public: Date(); Date( int, int ); Date( int, int, int );
  • 2. Date( string, int, int ); void setDay11(int); void setMonth11( int ); void print11() const; void printDDDYYYY11( ) const; void printMMDDYY11( ) const; void printMonthDDYYYY11( ) const; ~Date(); private: int month1; int day1; int year1;
  • 3. int checkDay(int)const; int daysInMonth(int)const; bool isLeapYear()const; int convertDDToDDD()const; void setMMDDFromDDD(int); string convertMMToMonth(int)const; void setMMFromMonth(string); int convertYYYYToYY()const; void setYYYYFromYY(int); }; #endif
  • 4. //Main.cpp include using std::cout; using std::endl; #include "Date.h" int main() { Date date1( 252,1999 ); Date date2( 2,25,04 ); Date date3( "September", 1, 2000 ); Date date4; date1.print11(); date2.print11();
  • 5. date3.print11(); date4.print11(); cout << ' '; date1.printDDDYYYY11(); date2.printDDDYYYY11(); date3.printDDDYYYY11(); date4.printDDDYYYY11(); cout << ' '; date1.printMMDDYY11(); date2.printMMDDYY11(); date3.printMMDDYY11(); date4.printMMDDYY11();
  • 7. #include using std::setw; using std::setfill; include using std::time; using std::localtime; using std::tm; using std::time_t; #include "Date.h" Date::Date() { struct tm *ptr;
  • 8. time_t t1 = time( 0 ); ptr = localtime( &t1 ); day1 = ptr->tm_mday; month1 = 1 + ptr->tm_mon; year1 = ptr->tm_year + 1900; } Date::Date( int ddd1, int yyyy1 ) { year1=yyyy1; setMMDDFromDDD(ddd1); } Date::Date( int mm1, int dd1, int yy1 )
  • 9. { setYYYYFromYY( yy1 ); mm1 ); setDay11( dd1 ); } Date::Date(string monthName2,int dd1,int yyyy1) { setMMFromMonth(monthName2); setDay11(dd1); year1=yyyy1; } void Date::setDay11( int d1 )
  • 10. { day1 = checkDay(d1); } void Date::setMonth11( int m1 ) { if(m1>0&& m1<=12) month1=m1; else { month1=1; cout<<"invalid month("<0 && testDay<=daysInMonth(month1)) return testDay; if(month1==2 && testDay==29 && isLeapYear())
  • 11. return testDay; cout<<"invalid day("<=2000?year1-2000:year1-1900); } void Date::setYYYYFromYY(int yy) { year1=(yy<7?yy+2000:yy+1900); } Please make a comment for all the codes Or explain this program code!! //Date.h #ifndef DateFormat #define DateFormat #include
  • 12. using std::string; class Date { public: Date(); Date( int, int ); Date( int, int, int ); Date( string, int, int ); void setDay11(int); void setMonth11( int ); void print11() const; void printDDDYYYY11( ) const; void printMMDDYY11( ) const;
  • 13. void printMonthDDYYYY11( ) const; ~Date(); private: int month1; int day1; int year1; int checkDay(int)const; int daysInMonth(int)const; bool isLeapYear()const; int convertDDToDDD()const; void setMMDDFromDDD(int); string convertMMToMonth(int)const;
  • 14. void setMMFromMonth(string); int convertYYYYToYY()const; void setYYYYFromYY(int); }; #endif //Main.cpp include using std::cout; using std::endl; #include "Date.h" int main() {
  • 15. Date date1( 252,1999 ); Date date2( 2,25,04 ); Date date3( "September", 1, 2000 ); Date date4; date1.print11(); date2.print11(); date3.print11(); date4.print11(); cout << ' '; date1.printDDDYYYY11(); date2.printDDDYYYY11(); date3.printDDDYYYY11();
  • 16. date4.printDDDYYYY11(); cout << ' '; date1.printMMDDYY11(); date2.printMMDDYY11(); date3.printMMDDYY11(); date4.printMMDDYY11(); cout << endl; date1.printMonthDDYYYY11(); date2.printMonthDDYYYY11(); date3.printMonthDDYYYY11(); date4.printMonthDDYYYY11(); return 0;
  • 17. } //Date.cpp #include using std::cout; using std::endl; #include using std::setw; using std::setfill; include using std::time; using std::localtime;
  • 18. using std::tm; using std::time_t; #include "Date.h" Date::Date() { struct tm *ptr; time_t t1 = time( 0 ); ptr = localtime( &t1 ); day1 = ptr->tm_mday; month1 = 1 + ptr->tm_mon; year1 = ptr->tm_year + 1900; }
  • 19. Date::Date( int ddd1, int yyyy1 ) { year1=yyyy1; setMMDDFromDDD(ddd1); } Date::Date( int mm1, int dd1, int yy1 ) { setYYYYFromYY( yy1 ); mm1 ); setDay11( dd1 ); } Date::Date(string monthName2,int dd1,int yyyy1)
  • 20. { setMMFromMonth(monthName2); setDay11(dd1); year1=yyyy1; } void Date::setDay11( int d1 ) { day1 = checkDay(d1); } void Date::setMonth11( int m1 ) { if(m1>0&& m1<=12) month1=m1;
  • 21. else { month1=1; cout<<"invalid month("<0 && testDay<=daysInMonth(month1)) return testDay; if(month1==2 && testDay==29 && isLeapYear()) return testDay; cout<<"invalid day("<=2000?year1-2000:year1-1900); } void Date::setYYYYFromYY(int yy) { year1=(yy<7?yy+2000:yy+1900);
  • 22. } Please make a comment for all the codes Or explain this program code!! //Date.h #ifndef DateFormat #define DateFormat #include using std::string; class Date { public: Date(); Date( int, int ); Date( int, int, int );
  • 23. Date( string, int, int ); void setDay11(int); void setMonth11( int ); void print11() const; void printDDDYYYY11( ) const; void printMMDDYY11( ) const; void printMonthDDYYYY11( ) const; ~Date(); private: int month1; int day1; int year1;
  • 24. int checkDay(int)const; int daysInMonth(int)const; bool isLeapYear()const; int convertDDToDDD()const; void setMMDDFromDDD(int); string convertMMToMonth(int)const; void setMMFromMonth(string); int convertYYYYToYY()const; void setYYYYFromYY(int); }; #endif //Main.cpp
  • 25. include using std::cout; using std::endl; #include "Date.h" int main() { Date date1( 252,1999 ); Date date2( 2,25,04 ); Date date3( "September", 1, 2000 ); Date date4; date1.print11(); date2.print11();
  • 26. date3.print11(); date4.print11(); cout << ' '; date1.printDDDYYYY11(); date2.printDDDYYYY11(); date3.printDDDYYYY11(); date4.printDDDYYYY11(); cout << ' '; date1.printMMDDYY11(); date2.printMMDDYY11(); date3.printMMDDYY11(); date4.printMMDDYY11();
  • 28. #include using std::setw; using std::setfill; include using std::time; using std::localtime; using std::tm; using std::time_t; #include "Date.h" Date::Date() { struct tm *ptr;
  • 29. time_t t1 = time( 0 ); ptr = localtime( &t1 ); day1 = ptr->tm_mday; month1 = 1 + ptr->tm_mon; year1 = ptr->tm_year + 1900; } Date::Date( int ddd1, int yyyy1 ) { year1=yyyy1; setMMDDFromDDD(ddd1); } Date::Date( int mm1, int dd1, int yy1 )
  • 30. { setYYYYFromYY( yy1 ); include using std::cout; using std::endl; #include "Date.h" int main() { Date date1( 252,1999 ); Date date2( 2,25,04 ); Date date3( "September", 1, 2000 ); Date date4; date1.print11();
  • 31. date2.print11(); date3.print11(); date4.print11(); cout << ' '; date1.printDDDYYYY11(); date2.printDDDYYYY11(); date3.printDDDYYYY11(); date4.printDDDYYYY11(); cout << ' '; date1.printMMDDYY11(); date2.printMMDDYY11(); date3.printMMDDYY11();
  • 33. using std::endl; #include using std::setw; using std::setfill; include using std::time; using std::localtime; using std::tm; using std::time_t; #include "Date.h" Date::Date() {
  • 34. struct tm *ptr; time_t t1 = time( 0 ); ptr = localtime( &t1 ); day1 = ptr->tm_mday; month1 = 1 + ptr->tm_mon; year1 = ptr->tm_year + 1900; } Date::Date( int ddd1, int yyyy1 ) { year1=yyyy1; setMMDDFromDDD(ddd1); }
  • 35. Date::Date( int mm1, int dd1, int yy1 ) { setYYYYFromYY( yy1 ); include using std::time; using std::localtime; using std::tm; using std::time_t; #include "Date.h" Date::Date() { struct tm *ptr;
  • 36. time_t t1 = time( 0 ); ptr = localtime( &t1 ); day1 = ptr->tm_mday; month1 = 1 + ptr->tm_mon; year1 = ptr->tm_year + 1900; } Date::Date( int ddd1, int yyyy1 ) { year1=yyyy1; setMMDDFromDDD(ddd1); } Date::Date( int mm1, int dd1, int yy1 )
  • 37. { setYYYYFromYY( yy1 ); mm1 ); setDay11( dd1 ); } Date::Date(string monthName2,int dd1,int yyyy1) { setMMFromMonth(monthName2); setDay11(dd1); year1=yyyy1; } void Date::setDay11( int d1 ) {
  • 38. day1 = checkDay(d1); } void Date::setMonth11( int m1 ) { if(m1>0&& m1<=12) month1=m1; else { month1=1; cout<<"invalid month("<0&& m1<=12) month1=m1; else {
  • 39. month1=1; cout<<"invalid month("<0 && testDay<=daysInMonth(month1)) return testDay; if(month1==2 && testDay==29 && isLeapYear()) return testDay; cout<<"invalid day("<0 && testDay<=daysInMonth(month1)) return testDay; if(month1==2 && testDay==29 && isLeapYear()) return testDay; cout<<"invalid day("<=2000?year1-2000:year1-1900); } void Date::setYYYYFromYY(int yy)
  • 40. { year1=(yy<7?yy+2000:yy+1900); } { static const string months1[]={" ","January","February","March","April","May","June","July","August","September ","October","November","december"}; return months1[mm]; } void Date::setMMFromMonth(string m1) { bool matchFound=false; for(int k=1;k<=12&&!matchFound;k++) {
  • 42. { year1=(yy<7?yy+2000:yy+1900); } Solution //Date.h #ifndef DateFormat #define DateFormat #include using std::string; class Date { public: // constructor Date(); // parameterized consturctors Date( int, int ); Date( int, int, int ); Date( string, int, int ); // setters void setDay11(int); void setMonth11( int ); // print functions void print11() const; void printDDDYYYY11( ) const; void printMMDDYY11( ) const; void printMonthDDYYYY11( ) const; ~Date(); private: // variables
  • 43. int month1; int day1; int year1; // check valid day int checkDay(int)const; // count days in month int daysInMonth(int)const; // check leap year bool isLeapYear()const; // converter function int convertDDToDDD()const; // setter void setMMDDFromDDD(int); // converter function string convertMMToMonth(int)const; // setter void setMMFromMonth(string); // converter function int convertYYYYToYY()const; // setter void setYYYYFromYY(int); }; #endif //Date.cpp // input output library #include using std::cout; using std::endl; // library to set width and fill #include using std::setw; using std::setfill; // library to use time #include using std::time; using std::localtime;
  • 44. using std::tm; using std::time_t; #include "Date.h" // default constructor Date::Date() { // taking pointer to tm struct tm *ptr; // set time as 0 time_t t1 = time( 0 ); // pointer taking address of t1 ptr = localtime( &t1 ); // day1 holds the day value of ptr day1 = ptr->tm_mday; // month1 holds the month value of ptr month1 = 1 + ptr->tm_mon; // year1 holds the year value of ptr + 1900 year1 = ptr->tm_year + 1900; } // parameterized constructor Date::Date( int ddd1, int yyyy1 ) { // set year year1=yyyy1; // call the month from date function setMMDDFromDDD(ddd1); } // parameterized constructor Date::Date( int mm1, int dd1, int yy1 ) { // call the year from year function setYYYYFromYY( yy1 ); // set day function setDay11( dd1 ); } // parameterized constructor
  • 45. Date::Date(string monthName2,int dd1,int yyyy1) { // call the month from month function setMMFromMonth(monthName2); // setday setDay11(dd1); year1=yyyy1; } void Date::setDay11( int d1 ) { // check for valid day and set it day1 = checkDay(d1); } void Date::setMonth11( int m1 ) { // check for valid month and set it if(m1>0&& m1<=12) month1=m1; else { // end set month to 1 month1=1; cout<<"invalid month("<0 && testDay<=daysInMonth(month1)) return testDay; if(month1==2 && testDay==29 && isLeapYear()) return testDay; cout<<"invalid day("<=2000?year1-2000:year1-1900); } // other yer converter function void Date::setYYYYFromYY(int yy) { year1=(yy<7?yy+2000:yy+1900); } //Main.cpp // input output library
  • 46. #include using std::cout; using std::endl; #include "Date.h" int main() { // calling parameterized constructors Date date1( 252,1999 ); Date date2( 2,25,04 ); Date date3( "September", 1, 2000 ); // print dates Date date4; date1.print11(); date2.print11(); date3.print11(); date4.print11(); // print date to years cout << ' '; date1.printDDDYYYY11(); date2.printDDDYYYY11(); date3.printDDDYYYY11(); date4.printDDDYYYY11(); // print month to date to years cout << ' '; date1.printMMDDYY11(); date2.printMMDDYY11(); date3.printMMDDYY11(); date4.printMMDDYY11(); // print final dates cout << endl; date1.printMonthDDYYYY11(); date2.printMonthDDYYYY11(); date3.printMonthDDYYYY11(); date4.printMonthDDYYYY11(); return 0; }
  • 47. /* output: invalid day(193)set to 1 3/1/1999 3/25/2004 9/1/2000 10/11/2016 60 1999 85 2004 245 2000 285 2016 03/0199 03/2504 09/0100 10/1116 March 1,1999 March 25,2004 September 1,2000 October 11,2016 date object destructor for date10/11/2016 date object destructor for date9/1/2000 date object destructor for date3/25/2004 date object destructor for date3/1/1999 */