Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PLEASE DO IT IN C++ AND MAKE SURE YOUR OUTPUT MATCHES THE OUTPUT GIVEN. EXPLAIN

ID: 3603126 • Letter: P

Question

PLEASE DO IT IN C++ AND MAKE SURE YOUR OUTPUT MATCHES THE OUTPUT GIVEN. EXPLAIN AS YOU CODE. KEEP IT BASIC. LOOK AT THE BOTTOM FOR 3 FILES.

main.cpp

#include <iostream>

dateType.h

dateTypeImp.cpp

A basic class datelvpe is designed to implement the date in a program, but the member function setDate does not check whether the date is in valid format Rewrite the definition of the function setDate so that the values for the month (1 to 12), day (1 to 31), and year (4 digits) are checked before storing the date into the member variables. Add amember function, isLeapYear, to check whether a year is a leap year a. b. Sample Output onth: 13 ay: 25 ear: 2017 onth is not valid lease enter proper date format onth: 12 ay: 35 ear: 2816 ay is not valid lease enter proper date format onth: 12 ay: 31 ear: 20017 ear is not valid lease enter proper date format onth: 12 ay: 31 ear: 2017 2-31-2017 eap year- ress any key to continue .. .

Explanation / Answer

Hi I have changed code in main.cpp and dateTypeImpl.cpp

main.cpp

#include <iostream>

dateTypeImpl.cpp

//Implementation file date

#include <iostream>
#include "dateType.h"

using namespace std;

bool dateType::setDate(int month, int day, int year)
{
if(month<=12 && month!=0){
dMonth = month;
}else{
cout << "Month is not valid ";
return false;
}
  
int i=month;
  
if(i==1 || i==3 || i==5 || i==7 || i==8 || i==10 || i==12){
if(day<=31 && day!=0){
dDay = day;
}else{
cout << "Day is not valid ";
return false;
}
}else if(i==4 || i==6 || i==9 || i==11){
if(day<=30 && day!=0){
dDay = day;
}else{
cout << "Day is not valid ";
return false;
}
}else{
int check=0;
if(year%4==0){
check=28;
}else{
check=29;
}
if(day<=check && day!=0){
dDay = day;
}else{
cout << "Day is not valid ";
return false;
}
}
  
dMonth = month;
dDay = day;
dYear = year;
}

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

int dateType::getMonth() const
{
return dMonth;
}

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

void dateType::printDate() const
{
cout << dMonth << "-" << dDay << "-" << dYear;
}

  
dateType::dateType()
{
dMonth = 1;
dDay = 1;
dYear = 1990;
}
bool dateType::isLeapYear() const
{
if(dYear%4==0){
return true;
}else{
return false;
}
  
}

dateType.h

Output:

Month: 12                                                                                                             

Day: 05                                                                                                               

Year: 2016                                                                                                            

12-5-2016                                                                                                             

Leap year = 1                                                                                                         

Press any key to continue...  

Please check it and let me know any issues comment here. Thank you. all the best.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote