Write a program that prompts the user to enter the year and month in this order, and displays the number of days in the month. For example, if the user entered month 2 and year 2000, the program should display that February 2000 has 29 days. If the user entered month 3 and year 2005, the program should display that March 2005 has 31 days.

```

Enter a, b, c, d, e, f: 9.0 4.0 3 -5 -6 -21
x is -2.0 and y is 3.0



Enter a, b, c, d, e, f: 1.0 2.0 2 4 4 5
The equation has no solution

```


```
#include
using namespace std;

int main()
{
cout << "Enter a year: ";
int year;
cin >> year;

cout << "Enter a month in the year (e.g., 1 for Jan): ";
int month;
cin >> month;

int numberOfDaysInMonth = 0;

switch (month)
{
case 1:
cout << "January " << year;
numberOfDaysInMonth = 31;
break;
case 2:
cout << "Feburary " << year;
if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0))
numberOfDaysInMonth = 29;
else
numberOfDaysInMonth = 28;
break;
case 3:
cout << "March " << year;
numberOfDaysInMonth = 31;
break;
case 4:
cout << "April " << year;
numberOfDaysInMonth = 30;
break;
case 5:
cout << "May " << year;
numberOfDaysInMonth = 31;
break;
case 6:
cout << "June " << year;
numberOfDaysInMonth = 30;
break;
case 7:
cout << "July " << year;
numberOfDaysInMonth = 31;
break;
case 8:
cout << "August " << year;
numberOfDaysInMonth = 31;
break;
case 9:
cout << "September " << year;
numberOfDaysInMonth = 30;
break;
case 10:
cout << "October " << year;
numberOfDaysInMonth = 31;
break;
case 11:
cout << "November " << year;
numberOfDaysInMonth = 30;
break;
case 12:
cout << "December " << year;
numberOfDaysInMonth = 31;
break;
}

cout << " has " << numberOfDaysInMonth << " days";

return 0;
}
```

Computer Science & Information Technology

You might also like to view...

Which of the following is used to uniquely identify a computer on a network?

A. Network ID B. Serial number C. IP address D. Microsoft ID

Computer Science & Information Technology

You must assign a unique title to each content control.

Answer the following statement true (T) or false (F)

Computer Science & Information Technology

Netstat shows what ____________________ are active and can also provide statistics based on ports or protocols (TCP, UDP, and so on).

Fill in the blank(s) with the appropriate word(s).

Computer Science & Information Technology

Which of the following is not a flag that can be used in the printf format-control string?

a) 0 b) + c) / d) #

Computer Science & Information Technology