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
Introduction or background of corporal punishment in schools
tensa zangetsu [6.8K]

Answer:

Corporal punishment is a discipline method in which a supervising adult, such as a teacher, deliberately inflicts pain upon a child in response to a child's unacceptable behavior or inappropriate language. The goals of this type of punishment are usually to halt the offense immediately, prevent it from happening again, and set an example for others.

3 0
3 years ago
A(n)_________________printer is produce high-quality and is inexpensive *​
ziro4ka [17]

Answer:

ink jet

Explanation:

Great at producing photo quality prints and image-heavy documents, as inkjet printers do a better job of blending and producing vibrant colors than laser printers. The price of an inkjet printer is less than most laser printers.

3 0
3 years ago
2. A data catalog identifies all of the following, except: a. Attribute data type b. Attribute range of values c. Attribute cons
alexandr1967 [171]

Answer:

c. Attribute constraints

Explanation:

A data catalog identifies all of the following, except: "Attribute constraints"

The above statement is TRUE because a Data Catalog, a metadata management service, operates by searching for key data, understand and manage data for usefulness.

Data Catalog checks on the BigQuery datasets, tables, and views and checks both technical and business metadata by identifying the following attributes:

1. Data type

2. Range of values

3. Value for Instructor ID

5 0
2 years ago
The piston ring isn't a completely solid ring; instead, it's usually split at one point. This split or gap in the ring is called
Umnica [9.8K]
<span>Answer: Ring end gap
 Ring end gap is the split or gap in the ring. The piston ring is split at one point and it is not completely solid ring and the split/ gap is termed as ring end gap.</span>
8 0
3 years ago
Read 2 more answers
Why is it important to recognize web address endings? to know the type of information on a site to determine if the site’s infor
seraphim [82]

Answer: To know the type of information on a site.

Website address endings are known as domain extensions. In our current society, the domain extensions or website endings are indicators of what information or content the website will contain. By recognizing these domain extensions, you will have a clear understanding of what to expect from the website.

Some examples of these domain extensions are:

.edu

- The .edu extension indicates that the website is related to educational content.

.org

- The .org extensions indicates that the website is related to free organizations.

.com

- The ever famous .com extension is an indicator of a commercial type of website.

6 0
3 years ago
Read 2 more answers
Other questions:
  • When you sort a cell range using a to z or z to a, what is rearranged?
    5·1 answer
  • Write any 2 differences between implicit variables and explicit variables.​Plz tell :' (
    10·1 answer
  • Write a function decimalToBinaryRecursive that converts a decimal value to binary using recursion. This function takes a single
    11·1 answer
  • Suppose a data broker correctly identifies that your grandmother is addicted to playing online hearts. From its business intelli
    8·1 answer
  • For a class project, Jerome builds a simple circuit with a battery and three light bulbs. On his way to school, Jerome drops his
    9·1 answer
  • What are the synonyms for each word? :
    5·1 answer
  • How to Save Power-Point presentation as a single file Web page that can be uploaded to the World Wide Web ?
    14·1 answer
  • A student registers for a course in a university. Courses may have limited enrollment i.e a student must
    5·1 answer
  • "Rights and duties are two sides of the same coin." Explain with examples​
    5·1 answer
  • Given a sorted list of integers, output the middle integer. assume the number of integers is always odd.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!