Problem Statement: You are required to write a program that prompts the user to enter the month and year, and displays the number of days in that particular 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.
1
Expert's answer
2011-10-20T08:31:58-0400
#include <cstdlib> #include <iostream>
using namespace std; int mounth,year; int main(int argc, char *argv[]) { cout<<"enter month number : "; cin>>mounth; cout<<"enter year number : "; cin>>year; switch (mounth){ case 1: & cout<<"January "<<year<<" has 31 days"<<endl; & break; case 2: & if (year%4==0) cout<<"February "<<year<<" has 29 days"<<endl; & else cout<<"January "<<year<<" has 28 days"<<endl; & break; case 3: & cout<<"March "<<year<<" has 31 days"<<endl; & break; case 4: & cout<<"April "<<year<<" has 30 days"<<endl; & break; case 5: & cout<<"May "<<year<<" has 31 days"<<endl; & break; & case 6: & cout<<"June "<<year<<" has 30 days"<<endl; & break; & case 7: & cout<<"July "<<year<<" has 31 days"<<endl; & break; & case 8: & cout<<"August "<<year<<" has 31 days"<<endl; & break; case 9: & cout<<"September "<<year<<" has 30 days"<<endl; & break; case 10: & cout<<"October "<<year<<" has 31 days"<<endl; & break; & case 11: & cout<<"November "<<year<<" has 30 days"<<endl; & break; case 12: & cout<<"December "<<year<<" has 31 days"<<endl; & break; default: & cout<<"invalid month"<<endl; & break; }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments
We are pleased to assist you
thanks a lot. super
Leave a comment