1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
umka21 [38]
3 years ago
11

Instructions

Computers and Technology
1 answer:
e-lub [12.9K]3 years ago
6 0

Answer:

See explaination

Explanation:

dateType.h

#ifndef dateType_H

#define dateType_H

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 the 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-yyyy.

void isLeapYear() const;

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.

private:

int dMonth; //variable to store the month

int dDay; //variable to store the day

int dYear; //variable to store the year

};

#endif

dateType.cpp

#include <iostream>

#include "dateType.h"

using namespace std;

void dateType::setDate(int month, int day, int year)

{

// Checking month is valid

while(month<1 || month>12)

{

cout << "Enterd month "<<month<< " is wrong"<<endl;

cout << "Enter correct month"<<endl;

cin>>month;

}

dMonth = month;

// Checking date is valid

while(day<1 || day>31)

{

cout << "Enterd date "<<day<<" is wrong"<<endl;

cout<<"Enter correct date"<<endl;

cin>>day;

}

dDay = day;

int count_digits = 0;

int flag=0;

int year1;

// Counting number of digits in year

while(flag==0)

{

year1=year;

count_digits=0;

while (year) {

year /= 10;

count_digits++;

}

if(count_digits != 4)

{

cout << "Enterd year "<<year1<<" is wrong"<<endl;

cout<<"Enter correct year"<<endl;

cin>>year;

flag=0;

}

else

flag=1;

}

dYear = year1;

}

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;

}

void dateType::isLeapYear() const

{

if ( dYear%400 == 0)

cout<<endl<<dYear<< " is leap year.\n";

else if ( dYear%100 == 0)

cout<<endl<<dYear<< " is leap year.\n";

else if ( dYear%4 == 0 )

cout<<endl<<dYear<< " is leap year.\n";

else

cout<<endl<<dYear<< " is not leap year.\n";

}

//Constructor with parameters

dateType::dateType(int month, int day, int year)

{

// Checking month is valid

while(month<1 || month>12)

{

cout << "Enterd month "<<month<< " is wrong"<<endl;

cout << "Enter correct month"<<endl;

cin>>month;

}

dMonth = month;

// Checking date is valid

while(day<1 || day>31)

{

cout << "Enterd date "<<day<<" is wrong"<<endl;

cout<<"Enter correct date"<<endl;

cin>>day;

}

dDay = day;

int count_digits = 0;

int flag=0;

int year1;

// Counting number of digits in year

while(flag==0)

{

year1=year;

count_digits=0;

while (year) {

year /= 10;

count_digits++;

}

if(count_digits != 4)

{

cout << "Enterd year "<<year1<<" is wrong"<<endl;

cout<<"Enter correct year"<<endl;

cin>>year;

flag=0;

}

else

flag=1;

}

dYear = year1;

}

main.cpp

#include<iostream>

#include "dateType.h"

using namespace std;

int main()

{

dateType *dt1=new dateType();

cout<<"Date is "<<endl;

dt1->printDate();

cout<<endl;

dt1->isLeapYear();

cout<<endl;

dateType *dt2=new dateType(11,14,2019);

cout<<"Date is "<<endl;

dt2->printDate();

cout<<endl;

dt2->isLeapYear();

cout<<endl;

dt2->setDate(13,32,2016);

cout<<"Date is "<<endl;

dt2->printDate();

cout<<endl;

dt2->isLeapYear();

cout<<endl;

dt1->setDate(10,10,198);

cout<<"Date is "<<endl;

dt1->printDate();

cout<<endl;

dt1->isLeapYear();

cout<<endl;

system("pause");

return 0;

}

You might be interested in
Identify the following as True or False.
Leni [432]

Answer:

The answer to this question as follows:

1) False

2) False

3) True

Explanation:

The description of the above option as follows

  • In option 1, A single character variable must be contained in one quote mark, but it is based on the alphabet, which is a specific device, and the price of a continued character varies from one device to another, that's why it is false.
  • In option 2, This option is wrong because in assembly language the identifier value must not exceed the length than 247 characters.
  • In option 3, It is correct because in the variable declaration the first char should be a letter, _, @ or $letter. A total of 1-247 characters. The default case is insensitive.

5 0
3 years ago
Based on your research and understanding, write a 3- to 4-page Microsoft Word document that:
Over [174]

Answer:

....

Explanation:

3 0
3 years ago
In the game of economics, producers look to technological improvements to increase which of the following?
Vaselesa [24]
They're looking to increase productivity 
7 0
3 years ago
Read 2 more answers
A. Modify the FitnessTracker class that includes data fields for a fitness activity, the number of minutes spent participating,
Elenna [48]

Answer:

It keeps saying servers fully loaded

Explanation:

5 0
2 years ago
When a number gets assigned to a variable that already has a value __________?
Aleksandr-060686 [28]
A already assigned variable cannot be assigned twice You can make the variable change over to a new one or call a whole new one to assign one without a value or It might be possible to do v=n (v is variable and n is number / value)
3 0
2 years ago
Other questions:
  • Brenda wants to finish her presentation with a summary slide . She wants three key messages to appear on each of the photo clips
    6·2 answers
  • How do IT security workers help business
    5·1 answer
  • Which of the following payment types require you to pay upfront A. Money order and credit card B. Money orders and prepaid card
    9·2 answers
  • Please write a Java program.
    8·1 answer
  • Below is a 4-bit down-counter. What is the largest number of the counter if the initial state Q3Q2Q1Q0=0011? (D3 and Q3 are MSB,
    14·1 answer
  • ERP packages are always quite simple.<br><br> True<br><br> False
    5·1 answer
  • ___signs tell you what you can or can't do, and what you must do ?
    5·2 answers
  • Write a program that gets three input characters which are user's initials and displays them in a welcoming message. Then gets i
    12·1 answer
  • Write a program to demonstrate circular linked list with operations using pointers – insert
    13·1 answer
  • oe, a user, receives an email from a popular video streaming website. the email urges him to renew his membership. the message a
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!