Answer to Question #253834 in C++ for Comm

Question #253834


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-20T00:06:35-0400
#include <iostream>

using namespace std;

int main()
{
    string dayName = "Sun Mon Tue Wed Thu Fri Sat;
    int month, year;
    char ch;

    cout << "Enter a month and year between 1/1901 and 12/2099: ";
    cin >> month >> ch >> year;
    	if ((month > 1 && month < 12) && (year < 1901 && year > 2099)) true;
    		else cout << "Please enter a valid date.";		
	cout << endl;
	
    int firstDay;
    int day, Days, numDays;
    numDays = (year - 1901) * 365 + (year - 1901)/ 4;
	
	
	switch (month)
    {
       case 1: "January"
	   case 2: "Febuary"
	   		Days = (year % 4 == 0) ? 29: 28;
	   case 3: "March"
	   case 4: "April"
	   case 5: "May"
	   case 6: "June"
	   case 7: "July"
	   case 8: "August"
	   case 9: "September"
	   case 10: "October"
	   case 11: "November" 
	   case 12: "December"
	}
    firstDay = (2 + numDays) % 7; firstDay
	
    for (day = 1; day <= days; day++)
	{
		
    	if ((day + fisrtday) % 7 == 0)
    		cout << endl;
	}   
	cout << endl; 
	
	return numDays

    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