// Tiffany Sallee
// Lab6 (no page)
// Determine if month * day = specified year to produce an output message
# include <iostream>
# include <cstring>
# include <cmath>
using namespace std;
int main()
{
//variable declaration
int month = 0;
int day = 0;
int year = 0;
int first = 0;
int second = 0;
//input month
cout << "Please enter month in numeric form: ";
cin >> month;
// validate month format
if (month < 1 || month > 12)
{
cout << "Error! Please input valid month.\n" << endl;
cout << "Reenter month in numeric form: ";
cin >> month;
}
// input day
cout << "Please enter day in numeric form: ";
cin >> day;
//validate day format
{
if (day < 1 || day > 31);
{
cout << "Error! Please input valid day.\n" << endl;
cout << "Reenter day: ";
cin >> day;
}
if
(month == 2 && day > 28); // February has 28 days
{
cout << "Error! Please input valid day.\n" << endl;
cout << "Reenter day: ";
cin >> day;
}
if ((month==9||month==4||month==6||month==11)&&day>30));
// 30 days has Sept, Apr, June & Nov
{
cout << "Error! Please input valid day.\n" << endl;
cout << "Reenter day: ";
cin >> day;
}
// input year
cout << "Pleae enter year in 2 digit format: ";
cin >> year;
//validate year format
if (year > 99)
{
cout << "Error! Please input a valid year: ";
cin >> year;
}
// calculate formula to determine output
{
first = month*day;
cout << first<<endl;
}
if (first = year)
cout << "Your date is MAGIC!\n";
else
cout << "Your date is NOT magic.";
system ("pause");
return 0;
}