Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Programming From Problem Analysis to Program Design You must use the provided code and provide additional comments to changes. Below is the code from

C++ Programming From Problem Analysis to Program Design

You must use the provided code and provide additional comments to changes.

image text in transcribed

image text in transcribed

Below is the code from Programming Exercise #2

Main.cpp

//Preprocessor directives, header functions #include #include

//Header file for dateType #include "dateType.h" //Header file for setDate #include "setDate.h"

//Standard Library using namespace std;

int main() {//Begin void function main

int m, d, y; dateType date(0,0,0); //Constructor call

//Friendly message explaining the purpose of the program cout

cout

cout

//Prompt the user to enter the values cout > m;

cout > d;

cout > y;

date.setDate(m, d, y);

cout

if (check) cout

cout

cout

return 0; }//end main

DATETYPE.H

//Standard Library using namespace std;

class dateType {

public:

void setDate(int month, int day, int year); //Function to set the date. //The member variables dMonth, dDay, and dYear are set //according to parameters. //PostCondition: dMonth = month; dDay = day; dYear = year;

int getDay() const; //Function to return the day. //Postcondition: The value of dDay is returned.

int getMonth() const; //Function to return the month. //Postcondition: The value of dMonth is returned.

int getYear() const; //Function to return the year. //Postcondition: The value of dYear is returned.

void printDate() const; //Function to output the date in the form mm-dd-yyy.

dateType(int month = 1, int day = 1, int year = 1900); //Constructor to set the date //The member variables dMonth, dDay, and dYear are set //according to the parameters. //Postcondition: dMonth = month; dDay = day; dYear = year; // if no values are specified, the default // values are used to initialize the member variables.

bool isLeapYear(); //Function to check if the year. is LeapYear //Postcondition: bool value indicating leap year

private:

int dMonth; //variable to store the month int dDay; //variable to store the day int dYear; //variable to store the year };

SETDATE.H

//Standard Library using namespace std;

//Default Constructors for Month, Day, and Year int dateType::getMonth() const { return dMonth; }

int dateType::getDay() const { return dDay; }

int dateType::getYear() const { return dYear; }

dateTypeImp.cpp

//Preprocessor Directives #include #include

//dateType header file #include "dateType.h"

//Standard Library using namespace std;

//Member function definitions void dateType::setDate(int month, int day, int year) { int noDays;

if(year > 1900) { //Condition to check if the year is valid or not

dYear = year;

if(month

case 4: case 6: case 9: case 11: noDays = 30; break;

case 2: if(isLeapYear()) noDays = 29; else noDays = 28; break; }

if(day

bool dateType::isLeapYear() { //Function to conform whether the year is a leap year or not if (((dYear % 4 == 0) && (dYear % 100 != 0)) || dYear % 400 == 0) return true; // The year is a leap year and the days in February is 29 else return false; //The year is NOT a leap year and the days in February is 28 }

void dateType::printDate()const { cout

//Constructor dateType::dateType(int month, int day, int year) { setDate(month, day, year); }

pages 813-814 #6, #7 In Programming Exercise 2, the class dateType was designed and implemented to keep track of a date, but it has very limited operations. Redefine the class dateType so that it can perform the following operations on a date, in addition to the operations already defined: a. Set the month. b. Set the day. c.Set the year d. Return the month. e. Return the day. f. Return the year. g. Test whether the year is a leap year. h. Return the number of days in the month. For example, if the date is 3-12-2019, the number of days to be returned is 31 because there are 31 days in March. i. Return the number of days passed in the year. For example, if the date is 3-18-2019, the number of days passed in the year is 77. Note that the number of days returned also includes the current day . Return the number of days remaining in the year. For example, if the date is 3-18-2019, the number of days remaining in the year is 288. k. Calculate the new date by adding a fixed number of days to the date. For example, if the date is 3-18-2019 and the days to be added are 25, the new date is 4-12-2019

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Database Programming

Authors: Chris Fehily

1st Edition

1937842312, 978-1937842314

More Books

Students also viewed these Databases questions

Question

=+differences in home- and host-country costs of living?

Answered: 1 week ago

Question

=+derived from the assignment will balance the costs?

Answered: 1 week ago