Please be clear for comments and follow the guidelines thoroughly. It should be
ID: 3871057 • Letter: P
Question
Please be clear for comments and follow the guidelines thoroughly. It should be in C++. Thanks for your help.
Create a program that uses a switch statement and case statements to calculate the number of days in any given month based upon a user's input. February is a unique month. Prompt the user again to input the year if the user wants the number of days for February. Hint**". You will need to solve for leap year. Have the user input information. Make sure the program can deal with any integer input. If a number entered does not correspond to a month of the year print "Invalid Month." Attach a snipping photo of source code and output Sample: Please enter Month 1-12 31 days in January Please enter Month 1-12 You selected February, Please enter year: 2017 28 Days Please enter Month 1-12 You selected February, Please enter year: 202029 DaysExplanation / Answer
#include <iostream.h>
#include <conio.h>
void main()
{
clrscr();
int mon, y, i;
cout << "Please enter year ";
cin >> y;
cout << "Please enter month ";
cin >> mon;
for (i = 1; i <= 12; i++)
{
i = mon;
switch (mon)
{
case 1:
cout << " 31 days in january ";
break;
case 2:
if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0))
{
cout << "29 days in february ";
}
else
{
cout << " 28 days in february ";
}
break;
case 3:
cout << "31 days in march ";
break;
case 4:
cout<<"30 days in april ";
break;
case 5:
cout << "31 days in may ";
break;
case 6:
cout<<"30 days in june ";
break;
case 7:
cout << "31 days in july ";
break;
case 8:
cout << "31 days in August ";
break;
case 9:
cout<<"30 days in september ";
break;
case 10:
cout<<"31 days in october ";
break;
case 11:
cout<<"30 days in november ";
break;
case 12:
cout<<"31 days in december ";
break;
default:
cout << " wrong input ";
break;
}
}
getch();
}