In this project, you'll be building a calendar app, but one much simpler than that. Your app need only work for each of the 12 months in the year 2022. The user of your application will enter a...

1 answer below »

In this project, you'll be building a calendar app, but one much simpler than that. Your app need only work for each of the 12 months in the year 2022.


The user of your application will enter a positive integer number in the range [1..12], indicating the month. In response, you'll print the calendar for that month in 2022. Here are some samples:


> python Project1.py


Enter the number of a month [1..12]: 1




January 2022


Su Mo Tu We Th Fr Sa



1


2 3 4 5 6 7 8


9 10 11 12 13 14 15


16 17 18 19 20 21 22


23 24 25 26 27 28 29


30 31



> python Project1.py


Enter the number of a month [1..12]: 2




February 2022


Su Mo Tu We Th Fr Sa



1 2 3 4 5


6 7 8 9 10 11 12


13 14 15 16 17 18 19


20 21 22 23 24 25 26


27 28



> python Project1.py


Enter the number of a month [1..12]: 15



Month must be between 1 and 12. Try again!


Enter the number of a month [1..12]: -9



Month must be between 1 and 12. Try again!


Enter the number of a month [1..12]: 12




December 2022


Su Mo Tu We Th Fr Sa



1 2 3


4 5 6 7 8 9 10


11 12 13 14 15 16 17


18 19 20 21 22 23 24


25 26 27 28 29 30 31



>


That's all there is to it. Note that one way to accomplish this would be to write separate code for each month and just print it out, as you did with your initials in HW1.That is not allowed. You have to compute and print each calendar using the algorithm outlined below.


Here are some hints and requirements:


1. You must validate the user input. You can assume that the number entered is an integer, but not that it's in the range [1..12]. If it's not, ask the user to re-enter. Follow the example above. Allow any number of tries.


2. You'll need to know how many days are in each month. You don't need to worry about leap years; 2022 is not a leap year.


3. One of the hardest things about a general calendar app is figuring out on which day of the week the month begins. There is actually a general algorithm for that, but it's pretty complex. You should just build in the information about the start day for each month in 2022. Just look it up in the calendar for 2022 and code that into your program.


4. Print one blank line above and at least one blank line below the calendar.


5. The Month Year title line does not have to be exactly centered (but you are permitted to use the string.center method if you like to make it centered).


Here's the algorithm.


1. First, print a blank line, the line with month and year, and the line with days of the week, as illustrated above.


2. For the first line of numbers, print the correct number of spaces (depending on the first day of the month) to take you to the appropriate start column. It's 3 spaces for each empty column.


3. Suppose M is the number of days in the month specified. You'll print the numbers [1..M], each in an integer field of width 2 followed by a single space. Be sure to stay on the same line until you reach column 7.


4. Keep track of what column you're in. When the column reaches 7, print a newline and reset the column counter to 0.


5. When you're done print a couple of newlines. (If you only print one, it may take you to the next line, but not show an empty line.It's OK to have two blank lines sometimes, but you must have at least one.


This assignment requires you to use formatting, loops, conditionals, keep track of the columns, etc. Do not use constructs (like lists) that are not covered in slidesets 1-6. Note that slideset 6 covers functions and you are welcome to use functions if you like, but you aren't required to. Some useful functions you might write and use are:


def monthName( n ):



# Given the number of a month, return its name.



# Example, given n == 1, return "January"



def firstDayOfMonth( n ):



# Given a month in 2022, on which day (number)



# does it begin. Example, given n == 1, return 6,



# since January, 2022 begins on Saturday (day 6).



# It's best to number the days from [0..6].



def daysInMonth( n ):



# Given a month in 2022, how many days are in it?



# Example, given n == 2, return 28 since there are



# 28 days in February of 2022. You can obtain this



# information by looking at a calendar for 2022, or



# just use your knowledge of how many days are in



# each month.

Answered Same DayOct 08, 2021

Answer To: In this project, you'll be building a calendar app, but one much simpler than that. Your app need...

Vicky answered on Oct 08 2021
133 Votes
# Program to display calendar of the given month and year
# File: Project1.py
# Student:
# UT EID
:
# Course Name: CS303E
#
# Date Created:
# Date Last Modified:
def monthName( n ):
# Given the number of a month, return its name.
# Example, given n == 1, return "January"
if(n == 1):
return "January"
elif(n == 2):
return "February"
elif(n == 3):
return "March"
elif(n == 4):
return "April"
elif(n == 5):
return "May"
elif(n == 6):
return "June"
elif(n == 7):
return "July"
elif (n == 8):
return "August"
elif (n == 9):
return "September"
elif (n == 10):
return "October"
elif (n == 11):
return "November"
elif (n == 12):
return "December"
def daysInMonth( n ):
# Given a month in 2022, how many days are in it?
# Example, given n == 2, return 28 since there are
# 28 days...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here