8/7/2021 Lab 13 - The Date Class https://miracosta.instructure.com/courses/26283/assignments/616486?module_item_id= XXXXXXXXXX/3 Lab 13 - The Date Class Due Jul 29 by 11:59pm Points 20 Submitting a...

1 answer below »

In this lab you'll create a class that represents a date (month, day, year) using a header ".h" file and an implementation ".cpp" file.






8/7/2021 Lab 13 - The Date Class https://miracosta.instructure.com/courses/26283/assignments/616486?module_item_id=1191168 1/3 Lab 13 - The Date Class Due Jul 29 by 11:59pm Points 20 Submitting a file upload Start Assignment A "Date" class (20 points) Please perform this lab individually or in groups of 2 or 3. Module 13 – Dates Summary In this lab you'll create a class that represents a date (month, day, year) using a header ".h" file and an implementation ".cpp" file. Description Design a class called Date that has integer data members to store month, day, and year. All of the member functions except getters in the Date class should have prototypes inside the class, and have their definitions outside of the class. The class should have a three-parameter constructor that allows the date to be set at the time a new Date object is created. It's heading should be: Datee(inttmonth,,inttday,,inttyear)) with the following default values defined in the heading of the prototype: the default month should be 1 (January) the default day should will be 1 8/7/2021 Lab 13 - The Date Class https://miracosta.instructure.com/courses/26283/assignments/616486?module_item_id=1191168 2/3 the default year will be 2000 The constructor should print the values of the three parameters before doing any data validation. Be sure that your Date constructor accepts only reasonable values for month, day, and year: the month should be between 1 and 12 the day should be between 1 and the number of days in the selected month (use 29 for February) the year should be between 1900 and 2099 If the user tries to create a Date object using any invalid argument, then use default values of 1, 1, 2000 (i.e., January 1, 2000) for the values of month, day, and year. As a suggestion, you might create a private function named checkDates in the Date class which verifies the values of month, date, and year to these values. Call this function at the very of the code in the constructor and/or in setters. In addition to all getters and setters, the class should also have four member functions to print the date in the following four formats: 3/15/2019 March 15, 2019 15.March.2019 2019.03.15 Note that in the last format, the day and month are always displayed to 2 digits. Try to do this using the I/O manipulators setfill and setw, or else using one or more ternary operators. Only the getters should be defined inside the body of the class. All other function definitions should appear outside of the class (prototypes inside the class). The class should have a header file (Date.h) and a specification file (Date.cpp). Your main function should be in its own .cpp file. In main demonstrate what happens when the following month/day/year combinations are provided to your Date class constructor. For valid dates, please show that date using all 4 display formats. For invalid dates, just show one format. month 1, day 5, this year month 9, day 14, 1970 month 12, day 31, next year month 4, day 31, this year (invalid day) month 13, day 1, this year (invalid month) month 8, day 15, 2100 (invalid year) 8/7/2021 Lab 13 - The Date Class https://miracosta.instructure.com/courses/26283/assignments/616486?module_item_id=1191168 3/3 Submit all C++ program files (Date header, Date function implementations, and the file containing main) as well as print screens or snips showing the results of running your tester program with the six test cases above. Additional Files Next Lab none Lab 14 - Introduction To Arrays Homework for this Module Prior Lab Homework 13 Lab 12 - Traveling by Air https://miracosta.instructure.com/courses/26283/assignments/616487 https://miracosta.instructure.com/courses/26283/assignments/616473 https://miracosta.instructure.com/courses/26283/assignments/616485
Answered 50 days AfterAug 07, 2021

Answer To: 8/7/2021 Lab 13 - The Date Class...

Aditya answered on Sep 27 2021
132 Votes
#include "Date.h"
Date::Date(int month, int day, int year)
{
    this->month = month;
    this->day =
day;
    this->year = year;
    cout << "Day: " << day << ", Month: " << month << ", Year: " << year << endl;
    if (checkDate() == false)
    {
        day = 1;
        month = 1;
        year = 2000;
        cout << endl;
        printFormatOne();
        cout << endl;
    }
    else {
        cout << endl;
        printFormatOne();
        cout << endl;
        printFormatTwo();
        cout << endl;
        printFormatThree();
        cout << endl;
        printFormatFour();
        cout << endl;
    }
}
bool Date::checkDate()
{
    if (this->year < 1900 || this->year>2099)
        return false;
    if (this->month < 1 || this->month>12)
        return false;
    if (this->day < 1 || this->day>31)
        return false;
    bool leapYear = false;
    if...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here