Добавил:
Sputnik
Помощь с лабораторными, контрольными практическими и курсовыми работами по:
- Инженерной и компьютерной графике
- Прикладной механике
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:2 сем 1 курс С++ / ЛР 3 / main
.cpp#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;
}