How do i make the range of months from 1-12? How do i make the days of the months so it can be valid. For example 2 29 2003 is invalid because 2003 is not a leap year.
I have to use string variable to convert the month in numbers to letters. Im trying to get my program to look like this.
Sample Run 1:
Enter numeric values for month, day and year of the first date> 10 10 2005
October 10, 2005 is a date in a non-leap year.
Sample Run 2:
Enter numeric values for month, day and year of the second date> 1 10 1582
01/10/1582 is not a valid date.
Sample Run 3:
Enter numeric values for month, day and year of the first date> 2 29 2004
February 29, 2004 is a date in a leap year.
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstring>
usingnamespace std;
int main()
{
int month, day, year;
//Sample 1
cout << "Sample Run 1:" << endl;
cout << "Enter numeric values for month, day and year of the first date> ";
cin >> month >> day >> year;
if(year <= 1582)
cout << month << " " << day << " " << year << " is not a valid date.";
elseif(month
elseif(year % 4 == 0)
cout << month << " " << day << " " << year << " is a date in a leap year.";
elseif(year % 4 >0)
cout << month << " " << day << " " << year << " is a date in a non-leap year." << endl;
cout << endl;
return 0;
}
if (valid_month && valid_day && valid_year)
{
if (leapYear)
cout << monthInWords << " " << day << ", " << year << " is a date in a leap year.";
else
cout << monthInWords << " " << day << ", " << year << " is a date in a non-leap year.";
}
else
cout << month << "/" << day << "/" << year << " is not a valid date.";
how do i print the zeros in front of single numbers?
Sample Run 2:
Enter numeric values for month, day and year of the second date> 1 10 1582
01/10/1582 is not a valid date.