Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ConsoleApplication1.cpp : This file contains the 'main' function. Program execution begins and ends there.
- //
- #include <iostream>
- #include <string>
- using namespace std;
- class Date
- {
- private:
- int day;
- int month;
- int year;
- public:
- Date()
- {
- day = 0;
- month = 0;
- year = 0;
- }
- void setDay(int d)
- {
- if (d < 1 && d > 32) {
- cout << "Invalide day!" << endl;
- }
- else {
- d = day;
- }
- }
- void setMonth(int m)
- {
- if (m < 1 && m > 12) {
- cout << "Invalide month!" << endl;
- }
- else {
- m = month;
- }
- }
- void setYear(int y)
- {
- if (y < 1990 && y > 2023)
- {
- cout << "Invalide year!" << endl;
- }
- else
- {
- y = year;
- }
- }
- void showDate()
- {
- string monthName[] = { "January", "February", "March", "April",
- "May", "June", "July", "August", "September", "October",
- "November", "Decenber" };
- if (monthName[month - 1] == "February") {
- if (year % 400 == 0) {
- // cout << year << " is a leap year.";
- if (day < 1 && day > 30) {
- cout << "Invalid day!";
- }
- else {
- cout << day << " " << monthName[month - 1] << " " << year << endl;
- }
- }
- else {
- //cout << year << " is not a leap year.";
- if (day < 1 && day > 29) {
- cout << "Invalid day!";
- }
- else {
- cout << day << " " << monthName[month - 1] << " " << year << endl;
- }
- }
- }
- }
- };
- class Person
- {
- private:
- string name;
- string qualification;
- Date date;
- public:
- Person()
- {
- name = "";
- qualification = "";
- }
- Person(string Name, string Qualification)
- {
- Name = name;
- Qualification = qualification;
- }
- void setName(string names)
- {
- names = name;
- }
- string getName()
- {
- return name;
- }
- void setQualification(string quality)
- {
- quality = qualification;
- }
- string getQualificattion()
- {
- return qualification;
- }
- void setDate()
- {
- date.showDate();
- cout << endl;
- }
- };
- int main()
- {
- string names, quality;
- int persons = 0;
- Person p;
- Date d;
- cout << "Enter how many persons do you want to check:";
- cin >> persons;
- cout << endl;
- for (int i = 1; i <= persons; i++)
- {
- cout << "Enter name of person: ";
- cin >> names;
- cout << endl;
- cout << "Enter qualification: ";
- cin >> quality;
- cout << endl;
- cout << "Enter birthday DD/MM/YYYY:";
- int day, month, year;
- cin >> day >> month >> year;
- cout << endl;
- cout << day << " " << monthName[month - 1] << " " << year << endl;
- cin.get();
- cout << endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement