SlideShare a Scribd company logo
//Date.h
#ifndef DateFormat
#define DateFormat
#include
#include
class Date {
public:
Date();
Date(int, int);
Date(int, int, int);
Date(char *, int, int);
voidsetMonth(int);
voidsetDay(int);
voidsetYear(int);
voidprintDateSlash(void) const;
voidprintDateMonth(void) const;
voidprintDateDay(void) const;
constchar *monthName(void) const;
intleapYear(void) const;
intdaysOfMonth(void) const;
voidchange(int);
intchange1(void) const;
voidchange2(constchar * const);
constchar *monthList(int) const;
intdays(int) const;
private:
int day;
int month;
int year;
};
class main {
public:
main();
virtual~main();
};
#endif
//Date.cpp
#include"stdafx.h"
#include
#include
#include
#include "Date.h"
Date::Date()
{
struct tm *ptr;
time_t t = time( 0 );
ptr = localtime( &t );
day = ptr->tm_mday;
month = 1 + ptr->tm_mon;
year = ptr->tm_year + 1900;
}
Date::Date( int ss, int ppp )
{
setYear( ppp );
change(ss);
}
Date::Date( int mm, int day1, int yy )
{
setYear( yy + 1900 );
setMonth( mm );
setDay(day1);
}
Date::Date( char *mPtr, int day1, int ppp )
{
setYear( ppp );
change2( mPtr );
setDay(day1);
}
voidDate::setDay( int d1 )
{ day = d1 >= 1 && d1 <= daysOfMonth() ? d1 : 1; }
voidDate::setMonth( int m ) { month = m >= 1 && m <= 12 ? m : 1; }
voidDate::setYear( int y ) { year = y >= 1900 && y <= 1999 ? y : 1900; }
voidDate::printDateSlash( void ) const
{
cout<< month << '/' << day << '/' << year << ' '; }
voidDate::printDateMonth( void ) const
{
cout << monthName() << ' ' << day << ", " << year << ' '; }
voidDate::printDateDay( void ) const
{
cout << convert2() << ' ' << year << ' '; }
constchar *Date::monthName( void ) const { return monthList( month - 1 ); }
intDate::daysOfMonth( void ) const
{ return leapYear() && month == 2 ? 29 : days( month ); }
intDate::leapYear( void ) const
{
if ( year % 400 == 0 || ( year % 4 == 0 && year % 100 != 0 ) )
return 1;
else
return 0;
}
voidDate::convert1( int ss )
{
int dayTotal = 0;
if ( ss < 1 || ss > 366 )
ss = 1;
setMonth( 1 );
for ( int m = 1; m < 13 && ( dayTotal + daysOfMonth() ) < ss; ++m ) {
dayTotal += daysOfMonth();
setMonth( m + 1 );
}
setDay( ss - dayTotal );
setMonth( m );
}
intDate::change1( void ) const
{
int ss = 0;
for ( int m = 1; m < month; ++m )
ss += days( m );
ss += day;
return ss;
}
voidDate::change2( constchar * const mPtr )
{
int flag = 0;
for ( int subscript = 0; subscript < 12; ++subscript )
if (!strcmp( mPtr, monthList( subscript ) ) ) {
setMonth( subscript + 1 );
flag = 1;
break;
}
if ( !flag )
setMonth( 1 );
}
constchar *Date::monthList( int mm ) const
{
char *months[] = { "January", "February", "March", "April", "May",
"June", "July", "August", "September", "October",
"November", "December" };
return months[ mm ];
}
intDate::days( int m ) const
{
constint monthDays[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
return monthDays[ m - 1 ];
}
//main.cpp
#include "Date.h"
#include
using sts::cout
using std::endl
#include
#include
#include "p7_07.h"
int main()
{
Date p1( 9,13, 99 ), p2( 85, 2004 ),
p3, p4( "October", 7, 2015 );
p1.printDateSlash();
p2.printDateSlash();
p3.printDateSlash();
p4.printDateSlash();
p1.printDateDay();
p2.printDateDay();
p3.printDateDay();
p4.printDateDay();
p1.printDateMonth();
p2.printDateMonth();
p3.printDateMonth();
p4.printDateMonth();
return 0;
}
}
Solution
//Date.h
#ifndef DateFormat
#define DateFormat
#include
#include
class Date {
public:
Date();
Date(int, int);
Date(int, int, int);
Date(char *, int, int);
voidsetMonth(int);
voidsetDay(int);
voidsetYear(int);
voidprintDateSlash(void) const;
voidprintDateMonth(void) const;
voidprintDateDay(void) const;
constchar *monthName(void) const;
intleapYear(void) const;
intdaysOfMonth(void) const;
voidchange(int);
intchange1(void) const;
voidchange2(constchar * const);
constchar *monthList(int) const;
intdays(int) const;
private:
int day;
int month;
int year;
};
class main {
public:
main();
virtual~main();
};
#endif
//Date.cpp
#include"stdafx.h"
#include
#include
#include
#include "Date.h"
Date::Date()
{
struct tm *ptr;
time_t t = time( 0 );
ptr = localtime( &t );
day = ptr->tm_mday;
month = 1 + ptr->tm_mon;
year = ptr->tm_year + 1900;
}
Date::Date( int ss, int ppp )
{
setYear( ppp );
change(ss);
}
Date::Date( int mm, int day1, int yy )
{
setYear( yy + 1900 );
setMonth( mm );
setDay(day1);
}
Date::Date( char *mPtr, int day1, int ppp )
{
setYear( ppp );
change2( mPtr );
setDay(day1);
}
voidDate::setDay( int d1 )
{ day = d1 >= 1 && d1 <= daysOfMonth() ? d1 : 1; }
voidDate::setMonth( int m ) { month = m >= 1 && m <= 12 ? m : 1; }
voidDate::setYear( int y ) { year = y >= 1900 && y <= 1999 ? y : 1900; }
voidDate::printDateSlash( void ) const
{
cout<< month << '/' << day << '/' << year << ' '; }
voidDate::printDateMonth( void ) const
{
cout << monthName() << ' ' << day << ", " << year << ' '; }
voidDate::printDateDay( void ) const
{
cout << convert2() << ' ' << year << ' '; }
constchar *Date::monthName( void ) const { return monthList( month - 1 ); }
intDate::daysOfMonth( void ) const
{ return leapYear() && month == 2 ? 29 : days( month ); }
intDate::leapYear( void ) const
{
if ( year % 400 == 0 || ( year % 4 == 0 && year % 100 != 0 ) )
return 1;
else
return 0;
}
voidDate::convert1( int ss )
{
int dayTotal = 0;
if ( ss < 1 || ss > 366 )
ss = 1;
setMonth( 1 );
for ( int m = 1; m < 13 && ( dayTotal + daysOfMonth() ) < ss; ++m ) {
dayTotal += daysOfMonth();
setMonth( m + 1 );
}
setDay( ss - dayTotal );
setMonth( m );
}
intDate::change1( void ) const
{
int ss = 0;
for ( int m = 1; m < month; ++m )
ss += days( m );
ss += day;
return ss;
}
voidDate::change2( constchar * const mPtr )
{
int flag = 0;
for ( int subscript = 0; subscript < 12; ++subscript )
if (!strcmp( mPtr, monthList( subscript ) ) ) {
setMonth( subscript + 1 );
flag = 1;
break;
}
if ( !flag )
setMonth( 1 );
}
constchar *Date::monthList( int mm ) const
{
char *months[] = { "January", "February", "March", "April", "May",
"June", "July", "August", "September", "October",
"November", "December" };
return months[ mm ];
}
intDate::days( int m ) const
{
constint monthDays[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
return monthDays[ m - 1 ];
}
//main.cpp
#include "Date.h"
#include
using sts::cout
using std::endl
#include
#include
#include "p7_07.h"
int main()
{
Date p1( 9,13, 99 ), p2( 85, 2004 ),
p3, p4( "October", 7, 2015 );
p1.printDateSlash();
p2.printDateSlash();
p3.printDateSlash();
p4.printDateSlash();
p1.printDateDay();
p2.printDateDay();
p3.printDateDay();
p4.printDateDay();
p1.printDateMonth();
p2.printDateMonth();
p3.printDateMonth();
p4.printDateMonth();
return 0;
}
}

More Related Content

Similar to Date.h#ifndef DateFormat#define DateFormat#includetime.h.pdf

Modify the Date class that was covered in the lecture which overload.pdf
Modify the Date class that was covered in the lecture which overload.pdfModify the Date class that was covered in the lecture which overload.pdf
Modify the Date class that was covered in the lecture which overload.pdf
saxenaavnish1
 
publicclass Date {privatestatic String DATE_SEPARATOR = ;pr.pdf
publicclass Date {privatestatic String DATE_SEPARATOR = ;pr.pdfpublicclass Date {privatestatic String DATE_SEPARATOR = ;pr.pdf
publicclass Date {privatestatic String DATE_SEPARATOR = ;pr.pdf
mukhtaransarcloth
 
Project presentation(View calender)
Project presentation(View calender)Project presentation(View calender)
Project presentation(View calender)
Ikhtiar Khan Sohan
 
COM1407: Structures, Unions & Dynamic Memory Allocation
COM1407: Structures, Unions & Dynamic Memory Allocation COM1407: Structures, Unions & Dynamic Memory Allocation
COM1407: Structures, Unions & Dynamic Memory Allocation
Hemantha Kulathilake
 
Jsr310
Jsr310Jsr310
Jsr310
彥彬 洪
 
#include iostream #include iomanip needed for formatting .docx
#include iostream #include iomanip  needed for formatting .docx#include iostream #include iomanip  needed for formatting .docx
#include iostream #include iomanip needed for formatting .docx
ajoy21
 
Python and PostgreSQL: Let's Work Together! | PyConFr 2018 | Dimitri Fontaine
Python and PostgreSQL: Let's Work Together! | PyConFr 2018 | Dimitri FontainePython and PostgreSQL: Let's Work Together! | PyConFr 2018 | Dimitri Fontaine
Python and PostgreSQL: Let's Work Together! | PyConFr 2018 | Dimitri Fontaine
Citus Data
 
structure
structurestructure
Computer programming 2 Lesson 14
Computer programming 2  Lesson 14Computer programming 2  Lesson 14
Computer programming 2 Lesson 14
MLG College of Learning, Inc
 
C Programming :- An Example
C Programming :- An Example C Programming :- An Example
C Programming :- An Example
Atit Gaonkar
 
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
 
Need to make a Java program which calculates the number of days betw.pdf
Need to make a Java program which calculates the number of days betw.pdfNeed to make a Java program which calculates the number of days betw.pdf
Need to make a Java program which calculates the number of days betw.pdf
anjandavid
 
C programs
C programsC programs
C programs
Adnan Vallippadan
 
From the proposal to ECMAScript – Step by Step
From the proposal to ECMAScript – Step by StepFrom the proposal to ECMAScript – Step by Step
From the proposal to ECMAScript – Step by Step
Igalia
 
A scrupulous code review - 15 bugs in C++ code
A scrupulous code review - 15 bugs in C++ codeA scrupulous code review - 15 bugs in C++ code
A scrupulous code review - 15 bugs in C++ code
PVS-Studio LLC
 
Help with the following code1. Rewrite to be contained in a vecto.pdf
Help with the following code1. Rewrite to be contained in a vecto.pdfHelp with the following code1. Rewrite to be contained in a vecto.pdf
Help with the following code1. Rewrite to be contained in a vecto.pdf
ezzi97
 
Structure & union
Structure & unionStructure & union
Structure & union
Rupesh Mishra
 
cprogramming Structures.pptx
cprogramming Structures.pptxcprogramming Structures.pptx
cprogramming Structures.pptx
LECO9
 

Similar to Date.h#ifndef DateFormat#define DateFormat#includetime.h.pdf (20)

Modify the Date class that was covered in the lecture which overload.pdf
Modify the Date class that was covered in the lecture which overload.pdfModify the Date class that was covered in the lecture which overload.pdf
Modify the Date class that was covered in the lecture which overload.pdf
 
publicclass Date {privatestatic String DATE_SEPARATOR = ;pr.pdf
publicclass Date {privatestatic String DATE_SEPARATOR = ;pr.pdfpublicclass Date {privatestatic String DATE_SEPARATOR = ;pr.pdf
publicclass Date {privatestatic String DATE_SEPARATOR = ;pr.pdf
 
Project presentation(View calender)
Project presentation(View calender)Project presentation(View calender)
Project presentation(View calender)
 
Introduction to c part 2
Introduction to c   part  2Introduction to c   part  2
Introduction to c part 2
 
COM1407: Structures, Unions & Dynamic Memory Allocation
COM1407: Structures, Unions & Dynamic Memory Allocation COM1407: Structures, Unions & Dynamic Memory Allocation
COM1407: Structures, Unions & Dynamic Memory Allocation
 
Jsr310
Jsr310Jsr310
Jsr310
 
#include iostream #include iomanip needed for formatting .docx
#include iostream #include iomanip  needed for formatting .docx#include iostream #include iomanip  needed for formatting .docx
#include iostream #include iomanip needed for formatting .docx
 
Python and PostgreSQL: Let's Work Together! | PyConFr 2018 | Dimitri Fontaine
Python and PostgreSQL: Let's Work Together! | PyConFr 2018 | Dimitri FontainePython and PostgreSQL: Let's Work Together! | PyConFr 2018 | Dimitri Fontaine
Python and PostgreSQL: Let's Work Together! | PyConFr 2018 | Dimitri Fontaine
 
structure
structurestructure
structure
 
Computer programming 2 Lesson 14
Computer programming 2  Lesson 14Computer programming 2  Lesson 14
Computer programming 2 Lesson 14
 
C Programming :- An Example
C Programming :- An Example C Programming :- An Example
C Programming :- An Example
 
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
 
Need to make a Java program which calculates the number of days betw.pdf
Need to make a Java program which calculates the number of days betw.pdfNeed to make a Java program which calculates the number of days betw.pdf
Need to make a Java program which calculates the number of days betw.pdf
 
Vcs29
Vcs29Vcs29
Vcs29
 
C programs
C programsC programs
C programs
 
From the proposal to ECMAScript – Step by Step
From the proposal to ECMAScript – Step by StepFrom the proposal to ECMAScript – Step by Step
From the proposal to ECMAScript – Step by Step
 
A scrupulous code review - 15 bugs in C++ code
A scrupulous code review - 15 bugs in C++ codeA scrupulous code review - 15 bugs in C++ code
A scrupulous code review - 15 bugs in C++ code
 
Help with the following code1. Rewrite to be contained in a vecto.pdf
Help with the following code1. Rewrite to be contained in a vecto.pdfHelp with the following code1. Rewrite to be contained in a vecto.pdf
Help with the following code1. Rewrite to be contained in a vecto.pdf
 
Structure & union
Structure & unionStructure & union
Structure & union
 
cprogramming Structures.pptx
cprogramming Structures.pptxcprogramming Structures.pptx
cprogramming Structures.pptx
 

More from angelfragranc

C ) common in nature, but commonly used psychological measures rare.pdf
 C ) common in nature, but commonly used psychological measures rare.pdf C ) common in nature, but commonly used psychological measures rare.pdf
C ) common in nature, but commonly used psychological measures rare.pdf
angelfragranc
 
Question evidence 1. Comparison of DNA sequences among single-ce.pdf
    Question evidence   1. Comparison of DNA sequences among single-ce.pdf    Question evidence   1. Comparison of DNA sequences among single-ce.pdf
Question evidence 1. Comparison of DNA sequences among single-ce.pdf
angelfragranc
 
The purpose of alchol (ethanol) is to dissolve io.pdf
                     The purpose of alchol (ethanol) is to dissolve io.pdf                     The purpose of alchol (ethanol) is to dissolve io.pdf
The purpose of alchol (ethanol) is to dissolve io.pdf
angelfragranc
 
The components may not separate properly, because.pdf
                     The components may not separate properly, because.pdf                     The components may not separate properly, because.pdf
The components may not separate properly, because.pdf
angelfragranc
 
The answer would be 5 because Dehydration in a .pdf
                     The answer would be 5 because  Dehydration in a .pdf                     The answer would be 5 because  Dehydration in a .pdf
The answer would be 5 because Dehydration in a .pdf
angelfragranc
 
SO3 Sol.pdf
                     SO3                                       Sol.pdf                     SO3                                       Sol.pdf
SO3 Sol.pdf
angelfragranc
 
Nucleophile is any negative ion or any neutral mo.pdf
                     Nucleophile is any negative ion or any neutral mo.pdf                     Nucleophile is any negative ion or any neutral mo.pdf
Nucleophile is any negative ion or any neutral mo.pdf
angelfragranc
 
Moles of acid (HNO2) = Vol conc = 0.52 = 1 mol.pdf
                     Moles of acid (HNO2) = Vol  conc = 0.52 = 1 mol.pdf                     Moles of acid (HNO2) = Vol  conc = 0.52 = 1 mol.pdf
Moles of acid (HNO2) = Vol conc = 0.52 = 1 mol.pdf
angelfragranc
 
it is a salt formed by KOH and HCl it is a neutra.pdf
                     it is a salt formed by KOH and HCl it is a neutra.pdf                     it is a salt formed by KOH and HCl it is a neutra.pdf
it is a salt formed by KOH and HCl it is a neutra.pdf
angelfragranc
 
Cultural competence refers to an ability to inter.pdf
                     Cultural competence refers to an ability to inter.pdf                     Cultural competence refers to an ability to inter.pdf
Cultural competence refers to an ability to inter.pdf
angelfragranc
 
Conformers can also be named as conformational is.pdf
                     Conformers can also be named as conformational is.pdf                     Conformers can also be named as conformational is.pdf
Conformers can also be named as conformational is.pdf
angelfragranc
 
Cl S Se Solution Cl .pdf
                     Cl  S  Se  Solution                     Cl .pdf                     Cl  S  Se  Solution                     Cl .pdf
Cl S Se Solution Cl .pdf
angelfragranc
 
benzene sulphonic acid - SO3H on benzene ring .pdf
                     benzene sulphonic acid  - SO3H on benzene ring   .pdf                     benzene sulphonic acid  - SO3H on benzene ring   .pdf
benzene sulphonic acid - SO3H on benzene ring .pdf
angelfragranc
 
The HTML was developed by Tim Berners Lee, to create electronic docu.pdf
The HTML was developed by Tim Berners Lee, to create electronic docu.pdfThe HTML was developed by Tim Berners Lee, to create electronic docu.pdf
The HTML was developed by Tim Berners Lee, to create electronic docu.pdf
angelfragranc
 
The genotype of happy skipping smurf 2 – Hs hSSolutionThe ge.pdf
The genotype of happy skipping smurf 2 – Hs  hSSolutionThe ge.pdfThe genotype of happy skipping smurf 2 – Hs  hSSolutionThe ge.pdf
The genotype of happy skipping smurf 2 – Hs hSSolutionThe ge.pdf
angelfragranc
 
ans D because NO2 has higher priority and should.pdf
                     ans D because NO2 has higher priority and should.pdf                     ans D because NO2 has higher priority and should.pdf
ans D because NO2 has higher priority and should.pdf
angelfragranc
 
The objective of the above code is to define a phonebook entry in ja.pdf
The objective of the above code is to define a phonebook entry in ja.pdfThe objective of the above code is to define a phonebook entry in ja.pdf
The objective of the above code is to define a phonebook entry in ja.pdf
angelfragranc
 
A. He has a smaller radius than H because He has .pdf
                     A. He has a smaller radius than H because He has .pdf                     A. He has a smaller radius than H because He has .pdf
A. He has a smaller radius than H because He has .pdf
angelfragranc
 
standard deviation = 0Solutionstandard deviation = 0.pdf
standard deviation = 0Solutionstandard deviation = 0.pdfstandard deviation = 0Solutionstandard deviation = 0.pdf
standard deviation = 0Solutionstandard deviation = 0.pdf
angelfragranc
 
A transducer is a device, usually electrical, ele.pdf
                     A transducer is a device, usually electrical, ele.pdf                     A transducer is a device, usually electrical, ele.pdf
A transducer is a device, usually electrical, ele.pdf
angelfragranc
 

More from angelfragranc (20)

C ) common in nature, but commonly used psychological measures rare.pdf
 C ) common in nature, but commonly used psychological measures rare.pdf C ) common in nature, but commonly used psychological measures rare.pdf
C ) common in nature, but commonly used psychological measures rare.pdf
 
Question evidence 1. Comparison of DNA sequences among single-ce.pdf
    Question evidence   1. Comparison of DNA sequences among single-ce.pdf    Question evidence   1. Comparison of DNA sequences among single-ce.pdf
Question evidence 1. Comparison of DNA sequences among single-ce.pdf
 
The purpose of alchol (ethanol) is to dissolve io.pdf
                     The purpose of alchol (ethanol) is to dissolve io.pdf                     The purpose of alchol (ethanol) is to dissolve io.pdf
The purpose of alchol (ethanol) is to dissolve io.pdf
 
The components may not separate properly, because.pdf
                     The components may not separate properly, because.pdf                     The components may not separate properly, because.pdf
The components may not separate properly, because.pdf
 
The answer would be 5 because Dehydration in a .pdf
                     The answer would be 5 because  Dehydration in a .pdf                     The answer would be 5 because  Dehydration in a .pdf
The answer would be 5 because Dehydration in a .pdf
 
SO3 Sol.pdf
                     SO3                                       Sol.pdf                     SO3                                       Sol.pdf
SO3 Sol.pdf
 
Nucleophile is any negative ion or any neutral mo.pdf
                     Nucleophile is any negative ion or any neutral mo.pdf                     Nucleophile is any negative ion or any neutral mo.pdf
Nucleophile is any negative ion or any neutral mo.pdf
 
Moles of acid (HNO2) = Vol conc = 0.52 = 1 mol.pdf
                     Moles of acid (HNO2) = Vol  conc = 0.52 = 1 mol.pdf                     Moles of acid (HNO2) = Vol  conc = 0.52 = 1 mol.pdf
Moles of acid (HNO2) = Vol conc = 0.52 = 1 mol.pdf
 
it is a salt formed by KOH and HCl it is a neutra.pdf
                     it is a salt formed by KOH and HCl it is a neutra.pdf                     it is a salt formed by KOH and HCl it is a neutra.pdf
it is a salt formed by KOH and HCl it is a neutra.pdf
 
Cultural competence refers to an ability to inter.pdf
                     Cultural competence refers to an ability to inter.pdf                     Cultural competence refers to an ability to inter.pdf
Cultural competence refers to an ability to inter.pdf
 
Conformers can also be named as conformational is.pdf
                     Conformers can also be named as conformational is.pdf                     Conformers can also be named as conformational is.pdf
Conformers can also be named as conformational is.pdf
 
Cl S Se Solution Cl .pdf
                     Cl  S  Se  Solution                     Cl .pdf                     Cl  S  Se  Solution                     Cl .pdf
Cl S Se Solution Cl .pdf
 
benzene sulphonic acid - SO3H on benzene ring .pdf
                     benzene sulphonic acid  - SO3H on benzene ring   .pdf                     benzene sulphonic acid  - SO3H on benzene ring   .pdf
benzene sulphonic acid - SO3H on benzene ring .pdf
 
The HTML was developed by Tim Berners Lee, to create electronic docu.pdf
The HTML was developed by Tim Berners Lee, to create electronic docu.pdfThe HTML was developed by Tim Berners Lee, to create electronic docu.pdf
The HTML was developed by Tim Berners Lee, to create electronic docu.pdf
 
The genotype of happy skipping smurf 2 – Hs hSSolutionThe ge.pdf
The genotype of happy skipping smurf 2 – Hs  hSSolutionThe ge.pdfThe genotype of happy skipping smurf 2 – Hs  hSSolutionThe ge.pdf
The genotype of happy skipping smurf 2 – Hs hSSolutionThe ge.pdf
 
ans D because NO2 has higher priority and should.pdf
                     ans D because NO2 has higher priority and should.pdf                     ans D because NO2 has higher priority and should.pdf
ans D because NO2 has higher priority and should.pdf
 
The objective of the above code is to define a phonebook entry in ja.pdf
The objective of the above code is to define a phonebook entry in ja.pdfThe objective of the above code is to define a phonebook entry in ja.pdf
The objective of the above code is to define a phonebook entry in ja.pdf
 
A. He has a smaller radius than H because He has .pdf
                     A. He has a smaller radius than H because He has .pdf                     A. He has a smaller radius than H because He has .pdf
A. He has a smaller radius than H because He has .pdf
 
standard deviation = 0Solutionstandard deviation = 0.pdf
standard deviation = 0Solutionstandard deviation = 0.pdfstandard deviation = 0Solutionstandard deviation = 0.pdf
standard deviation = 0Solutionstandard deviation = 0.pdf
 
A transducer is a device, usually electrical, ele.pdf
                     A transducer is a device, usually electrical, ele.pdf                     A transducer is a device, usually electrical, ele.pdf
A transducer is a device, usually electrical, ele.pdf
 

Recently uploaded

TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
EugeneSaldivar
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Po-Chuan Chen
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
SACHIN R KONDAGURI
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
Nguyen Thanh Tu Collection
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
Tamralipta Mahavidyalaya
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 

Recently uploaded (20)

TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...TESDA TM1 REVIEWER  FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
TESDA TM1 REVIEWER FOR NATIONAL ASSESSMENT WRITTEN AND ORAL QUESTIONS WITH A...
 
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdfAdversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
Adversarial Attention Modeling for Multi-dimensional Emotion Regression.pdf
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
"Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe..."Protectable subject matters, Protection in biotechnology, Protection of othe...
"Protectable subject matters, Protection in biotechnology, Protection of othe...
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
BÀI TẬP BỔ TRỢ TIẾNG ANH GLOBAL SUCCESS LỚP 3 - CẢ NĂM (CÓ FILE NGHE VÀ ĐÁP Á...
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 

Date.h#ifndef DateFormat#define DateFormat#includetime.h.pdf

  • 1. //Date.h #ifndef DateFormat #define DateFormat #include #include class Date { public: Date(); Date(int, int); Date(int, int, int); Date(char *, int, int); voidsetMonth(int); voidsetDay(int); voidsetYear(int); voidprintDateSlash(void) const; voidprintDateMonth(void) const; voidprintDateDay(void) const; constchar *monthName(void) const; intleapYear(void) const; intdaysOfMonth(void) const; voidchange(int); intchange1(void) const; voidchange2(constchar * const); constchar *monthList(int) const; intdays(int) const; private: int day; int month; int year; }; class main { public: main(); virtual~main(); };
  • 2. #endif //Date.cpp #include"stdafx.h" #include #include #include #include "Date.h" Date::Date() { struct tm *ptr; time_t t = time( 0 ); ptr = localtime( &t ); day = ptr->tm_mday; month = 1 + ptr->tm_mon; year = ptr->tm_year + 1900; } Date::Date( int ss, int ppp ) { setYear( ppp ); change(ss); } Date::Date( int mm, int day1, int yy ) { setYear( yy + 1900 ); setMonth( mm ); setDay(day1); } Date::Date( char *mPtr, int day1, int ppp ) { setYear( ppp ); change2( mPtr ); setDay(day1); } voidDate::setDay( int d1 ) { day = d1 >= 1 && d1 <= daysOfMonth() ? d1 : 1; } voidDate::setMonth( int m ) { month = m >= 1 && m <= 12 ? m : 1; }
  • 3. voidDate::setYear( int y ) { year = y >= 1900 && y <= 1999 ? y : 1900; } voidDate::printDateSlash( void ) const { cout<< month << '/' << day << '/' << year << ' '; } voidDate::printDateMonth( void ) const { cout << monthName() << ' ' << day << ", " << year << ' '; } voidDate::printDateDay( void ) const { cout << convert2() << ' ' << year << ' '; } constchar *Date::monthName( void ) const { return monthList( month - 1 ); } intDate::daysOfMonth( void ) const { return leapYear() && month == 2 ? 29 : days( month ); } intDate::leapYear( void ) const { if ( year % 400 == 0 || ( year % 4 == 0 && year % 100 != 0 ) ) return 1; else return 0; } voidDate::convert1( int ss ) { int dayTotal = 0; if ( ss < 1 || ss > 366 ) ss = 1; setMonth( 1 ); for ( int m = 1; m < 13 && ( dayTotal + daysOfMonth() ) < ss; ++m ) { dayTotal += daysOfMonth(); setMonth( m + 1 ); } setDay( ss - dayTotal ); setMonth( m ); } intDate::change1( void ) const { int ss = 0;
  • 4. for ( int m = 1; m < month; ++m ) ss += days( m ); ss += day; return ss; } voidDate::change2( constchar * const mPtr ) { int flag = 0; for ( int subscript = 0; subscript < 12; ++subscript ) if (!strcmp( mPtr, monthList( subscript ) ) ) { setMonth( subscript + 1 ); flag = 1; break; } if ( !flag ) setMonth( 1 ); } constchar *Date::monthList( int mm ) const { char *months[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; return months[ mm ]; } intDate::days( int m ) const { constint monthDays[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; return monthDays[ m - 1 ]; } //main.cpp #include "Date.h" #include using sts::cout using std::endl #include #include
  • 5. #include "p7_07.h" int main() { Date p1( 9,13, 99 ), p2( 85, 2004 ), p3, p4( "October", 7, 2015 ); p1.printDateSlash(); p2.printDateSlash(); p3.printDateSlash(); p4.printDateSlash(); p1.printDateDay(); p2.printDateDay(); p3.printDateDay(); p4.printDateDay(); p1.printDateMonth(); p2.printDateMonth(); p3.printDateMonth(); p4.printDateMonth(); return 0; } } Solution //Date.h #ifndef DateFormat #define DateFormat #include #include class Date { public: Date(); Date(int, int); Date(int, int, int); Date(char *, int, int); voidsetMonth(int); voidsetDay(int);
  • 6. voidsetYear(int); voidprintDateSlash(void) const; voidprintDateMonth(void) const; voidprintDateDay(void) const; constchar *monthName(void) const; intleapYear(void) const; intdaysOfMonth(void) const; voidchange(int); intchange1(void) const; voidchange2(constchar * const); constchar *monthList(int) const; intdays(int) const; private: int day; int month; int year; }; class main { public: main(); virtual~main(); }; #endif //Date.cpp #include"stdafx.h" #include #include #include #include "Date.h" Date::Date() { struct tm *ptr; time_t t = time( 0 ); ptr = localtime( &t ); day = ptr->tm_mday; month = 1 + ptr->tm_mon;
  • 7. year = ptr->tm_year + 1900; } Date::Date( int ss, int ppp ) { setYear( ppp ); change(ss); } Date::Date( int mm, int day1, int yy ) { setYear( yy + 1900 ); setMonth( mm ); setDay(day1); } Date::Date( char *mPtr, int day1, int ppp ) { setYear( ppp ); change2( mPtr ); setDay(day1); } voidDate::setDay( int d1 ) { day = d1 >= 1 && d1 <= daysOfMonth() ? d1 : 1; } voidDate::setMonth( int m ) { month = m >= 1 && m <= 12 ? m : 1; } voidDate::setYear( int y ) { year = y >= 1900 && y <= 1999 ? y : 1900; } voidDate::printDateSlash( void ) const { cout<< month << '/' << day << '/' << year << ' '; } voidDate::printDateMonth( void ) const { cout << monthName() << ' ' << day << ", " << year << ' '; } voidDate::printDateDay( void ) const { cout << convert2() << ' ' << year << ' '; } constchar *Date::monthName( void ) const { return monthList( month - 1 ); } intDate::daysOfMonth( void ) const { return leapYear() && month == 2 ? 29 : days( month ); } intDate::leapYear( void ) const
  • 8. { if ( year % 400 == 0 || ( year % 4 == 0 && year % 100 != 0 ) ) return 1; else return 0; } voidDate::convert1( int ss ) { int dayTotal = 0; if ( ss < 1 || ss > 366 ) ss = 1; setMonth( 1 ); for ( int m = 1; m < 13 && ( dayTotal + daysOfMonth() ) < ss; ++m ) { dayTotal += daysOfMonth(); setMonth( m + 1 ); } setDay( ss - dayTotal ); setMonth( m ); } intDate::change1( void ) const { int ss = 0; for ( int m = 1; m < month; ++m ) ss += days( m ); ss += day; return ss; } voidDate::change2( constchar * const mPtr ) { int flag = 0; for ( int subscript = 0; subscript < 12; ++subscript ) if (!strcmp( mPtr, monthList( subscript ) ) ) { setMonth( subscript + 1 ); flag = 1; break; }
  • 9. if ( !flag ) setMonth( 1 ); } constchar *Date::monthList( int mm ) const { char *months[] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" }; return months[ mm ]; } intDate::days( int m ) const { constint monthDays[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; return monthDays[ m - 1 ]; } //main.cpp #include "Date.h" #include using sts::cout using std::endl #include #include #include "p7_07.h" int main() { Date p1( 9,13, 99 ), p2( 85, 2004 ), p3, p4( "October", 7, 2015 ); p1.printDateSlash(); p2.printDateSlash(); p3.printDateSlash(); p4.printDateSlash(); p1.printDateDay(); p2.printDateDay(); p3.printDateDay(); p4.printDateDay(); p1.printDateMonth();