We're Open
+44 7340 9595 39
+44 20 3239 6980

CALCULATED USING THE BIRTHDATE AND THE CURRENT DATE

  100% Pass and No Plagiarism Guaranteed

CALCULATED USING THE BIRTHDATE AND THE CURRENT DATE

In this paper, the current date and the age calculated using the birthdate and the current date and you are required to display the local date time created as birthdate and a header file age.h with code to prevent multiple inclusion. Also, provide a text file task_2_3.txt containing compilation messages and sample runs and include the code for class DateTime in age.h and age.cpp

 

Derive class Age from class DateTime such that Age::display() will display birthdate in local date time format using values from the parameters, the current time and the age.

class Age : public DateTime {

public:

// Date supplied is birth date, should be earlier than current date

Age(int y, int m, int d, int h = 0, int min = 0, int s = 0);

void display();

protected:

struct tm Astruct;   // tm for current time private:

string int_2_string(int);

void error_action();

string age;

};

string Age::int_2_string(int n){

ostringstream outstr;

if (n > 100000){

outstr << (n - 100000);

return outstr.str() + " days old.";

} else if (n > 1000){

outstr << (n - 1000);

return outstr.str() + " months old.";

} else {

outstr << n;

return outstr.str() + " years old.";

}

}

 

void Age::error_action(){

cout << "Birthday must be in the past!n";

exit(EXIT_FAILURE);

}

 

Implement

    Age(int y, int m, int d, int h = 0, int min = 0, int s = 0);

    Validate parameter values the same way as in class DateTime.

      When calculating age, the unit can be day, month or year. To differentiate the units, add 1,000 to age in months, add 100,000 to age in days. When passed to int_2_string, we can convert the age to proper values and units.

    void display();

      Display the local date time created as birthdate; the current date and the age calculated using the birthdate and the current date.

You have to provide:

    a header file age.h with code to prevent multiple inclusion.

    an class implementation file age.cpp.

    a text file task_2_3.txt containing compilation messages and sample runs. Note

    You have to include the code for class DateTime in age.h and age.cpp.

    You may include the code for class WeekDay in age.h and age.cpp.

 

      Do not modify DateTime and Age class public and protected sections. You may add private members (data/functions) only.

    There is no need to implement error exception.

 

You may use sample_AGE_app.cpp to test your implementation. Expected output:

 

C:>a

Birthday: 12/25/94 03:04:05

Current date: 04/15/15 15:17:15

Age is 22 years old.

 

Birthday: 12/25/94 03:04:00

Current date: 04/15/15 15:17:15

Age is 22 years old.

 

Birthday: 12/25/94 03:00:00

Current date: 04/15/15 15:17:15

Age is 22 years old.

 

Birthday: 12/25/94 00:00:00

Current date: 04/15/15 15:17:15

Age is 22 years old.

 

Birthday: 04/15/15 00:00:00

Current date: 04/15/15 15:17:15

Age is 1 days old.

 

Birthday: 04/01/15 00:00:00

Current date: 04/15/15 15:17:15

Age is 15 days old.

 

Birthday: 03/15/15 00:00:00

Current date: 04/15/15 15:17:15

Age is 2 months old.

 

Birthday: 12/25/14 00:00:00

Current date: 04/15/15 15:17:15

Age is 2 years old.

 

Birthday: 01/25/14 00:00:00

Current date: 04/15/15 15:17:15

Age is 2 years old.

 

You should also use your own test cases to test for error inputs.

 

Marking Criteria

Marks

Age() and display()

12

age.h with code to prevent multiple inclusion.

2

age.cpp

4

Compilation messages and sample run outputs (if the program runs correctly)

2

 

 

 


100% Plagiarism Free & Custom Written,
Tailored to your instructions


International House, 12 Constance Street, London, United Kingdom,
E16 2DQ

UK Registered Company # 11483120


100% Pass Guarantee

STILL NOT CONVINCED?

View our samples written by our professional writers to let you comprehend how your work is going to look like. We have categorised this into 3 categories with a few different subject domains

View Our Samples

We offer a £ 2999

If your assignment is plagiarised, we will give you £ 2999 in compensation

Recent Updates

Details

  • Title: CALCULATED USING THE BIRTHDATE AND THE CURRENT DATE
  • Price: £ 109
  • Post Date: 2020-04-04T10:05:47+00:00
  • Category: Assignment Queries
  • No Plagiarism Guarantee
  • 100% Custom Written

Customer Reviews

CALCULATED USING THE BIRTHDATE AND THE CURRENT DATE CALCULATED USING THE BIRTHDATE AND THE CURRENT DATE
Reviews: 5

A masterpiece of assignment by , written on 2020-03-12

This is my second order which I booked recently at Insta Research. I just got my coursework completed expertly. Just waiting for good scores now.
Reviews: 5

A masterpiece of assignment by , written on 2020-03-12

Very professional and effective assignment writing service.