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
Jabez needs to alert through an SMS text message those corporate users who have a specific brand and type of mobile device regar
Maslowich

Answer:

Push notification services.

Explanation:

Push notification services can be used to deliver important messages on mobile devices in an efficient and timely manner. The different mobile platforms such as android, iOS have their services which makes it easy for Jabez to send the messages to users with a specific brand and type of mobile device. The messages will pop up on the mobile device of the user, whether the app or the website associated with notifications is running or not.

7 0
3 years ago
What is communication​
IgorLugansk [536]

Answer:

it is when u talk to someone

6 0
3 years ago
Read 2 more answers
Select the correct answer. What is the purpose of preserving historical data? A. legal compliance B. recruitment C. leave sancti
Gre4nikov [31]

Answer:The main goal of data preservation is to protect data from being lost or destroyed and to contribute to the reuse and progression of the data.

Explanation:

8 0
3 years ago
Clicking the ____ deletes all letters in a box.
Luda [366]
Clicking Ctrl+a and backspace deletes all letters.<span />
6 0
3 years ago
What are the options for editing inserted'illustration items in Outlook messages? Check all that apply.
dimaraw [331]

Answer:

changing layout options

resizing the image

adding and editing shapes

adding and editing styles

Explanation:

Inserting screenshots requires no sort of editing. Also, no editing is required for inserting the tables and graphs. However, the options being mentioned in the answer section is an example of editing. Changing layout options is editing, resizing the images is editing, adding and editing shapes is editing as well as adding and editing styles is editing. Hence, the choices mentioned in the answer section are the correct options.

6 0
3 years ago
Read 2 more answers
Other questions:
  • A _____ is a machine that changes information from one form into another.
    7·1 answer
  • What do I need to write ??
    14·1 answer
  • Name three recent advances that are influencing OS design.
    15·1 answer
  • How do I answer a question that was answered incorrectly on Brainly
    10·2 answers
  • The way that text and images are arranged on a slide is called _________. A. Layout B. Background C. Style D. Charting
    10·2 answers
  • You can place an insertion point by clicking in the field or by pressing ____.
    13·1 answer
  • The computer system for a major retail store was hacked. Many addresses, credit card numbers, and other pieces of customers’ per
    7·2 answers
  • Programs for embedded devices are often written in assembly language. Some embedded processors have limited instructions, like M
    5·1 answer
  • The ______ Works on a single variable or constant. *​
    8·1 answer
  • List and discuss five economic growth indicators
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!