Answer to Question #253881 in C++ for Breexy

Question #253881

Write a program that will display a calendar given a month and year as an input to the program. Will display only single month of year given. Here it’s that if given input as ( April 2003) will display only the given month of the year.


1
Expert's answer
2021-10-20T07:39:10-0400
#include <iostream>
using namespace std;


int main()
{
    int month, year, days;
    char ch;


	cout << "Enter a month and year: ";
    cin >> month>> year;		
	while (true)
		{
			switch (month)
			{
				case 1: "January"; days = 31; break;
				case 2: "February"; days = 31;
					if (year % 4 != 0) days = 28;
						else days = 29; break;
				case 3: "March"; days = 31; break;
				case 4: "April"; days = 30; break;
				case 5: "May"; days = 31; break;
				case 6: "June"; days = 30; break;
				case 7: "July"; days = 31; break;
				case 8: "August"; days = 31; break;
				case 9: "September"; days = 30; break;
				case 10: "October"; days = 31; break;
				case 11: "November"; days = 30; break;
				case 12: "December "; days = 31; break;
				default: cout << "invalid month" << endl;
				
				cout << "Calendar: " << month << ", " << year; break;
				cout << "Sun Mon Tue Wed Thu Fri"; break;
					if (month < 12 && month > 1)
						{
							int numDays, firstDay, days, day;
							firstDay = (2 + numDays) % 7; firstDay;


   					   		 for (day = 1; day <= days; day++)
							{
	
								if ((day + firstDay) % 7 == 0)
								cout << endl;
							}   
			
						}	
			}
			
		}


    return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS