Добавил:
Помощь с лабораторными, контрольными практическими и курсовыми работами по: - Инженерной и компьютерной графике - Прикладной механике Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Скачиваний:
0
Добавлен:
08.08.2022
Размер:
1.37 Кб
Скачать
#include<iostream>
using namespace std;
class Date
{
public:
int day, month, year;
Date(int d, int m, int y) 
{                           
    day = d;    
    month = m;  
    year = y;   
}
 
Date(int d) 
{
    day = d; 
    month = 5; 
    year = 2021;
}
 
Date()  
{
    day = 1;    
    month = 1;  
    year = 2000; 
}
 
void Print()
{
    if(day <= 31 && month <= 12) 
    {
    cout << "You data: " << day << "." << month << "." << year;
        if(month <= 5 && month >= 3)
        {
            cout << " - Spring" << endl;
        }
        else cout << endl;
    }
    else cout <<"The entered date is incorrect" << endl;
}
};
int main()
{
    int day(0), month(0), year(0);  
    cout << "Enter five dates" << endl;
    for(int i = 0;i < 5;i++)
    {
 
    cout << "Enter the day (Put 0 if not present): ";
    cin >> day;
    cout << "Enter the month (Put 0 if missing): ";
    cin >> month;
    cout << "Enter the year (Put 0 if missing): ";
    cin >> year;
 
    if(month == 0 && year == 0 && day != 0)
    {
        Date A(day);
        A.Print();
    }
    if(month == 0 && year == 0 && day == 0)
    {
        Date A;
         A.Print();
    }
    if(month != 0 && year != 0 && day != 0)
    {
        Date A(day,month,year);
         A.Print();
    }
    }
 
    return 0; 
}
Соседние файлы в папке ЛР 3