Project 1 - Days in Month/Year
Due - Friday, February 9, 2007
The goal of this project is to give you experience using
conditionals and functions in Python. You will write a program
that prompts the user for a date specified by the month
(represented by a string), day, and year, and will print for the
user (1) the number of days from the date entered until the end of
the specified month and (2) the number of days from the date
specified until the end of the year. A sample run of your program
would look as follows:
Enter a string representation of the month: November
Enter a day: 30
Enter a year: 2007
There are 0 days remaining in the month.
There are 31 days remaining in the year.
Implementation Requirements and Hints
- For full credit, your program must implement, and correctly use, the following functions:
- monthStrToInt: This function takes as input a string representing a month and returns the integer representation of the month. For example, given the input "January" your function would return 1.
- getDaysInMonth: This function takes as input an int representation of a month and an int representation of a year and returns the total number of days in the month. For example, given the input (2, 2000) your function would return 29.
- isLeap: This function takes as input an int representation of a year and returns True if the year is a leap year and False otherwise. A year is a leap year if it is divisible by four. However, if a year is divisible by 100, it must also be divisible by 400 in order to be a leap year.
- getRemainingDaysInMonth: This function takes as input an int representing a day and an int representing the total number if days in the month in which the day occurs and returns the number of days remaining in the month.
- getRemainingDaysInYear: This function takes as input an int representing a day, an int representing a month, and an int representing the year and returns the number of days remaining in the year.
- printResults: This function takes as input an int representing the number of days remaining in the month and an int representing the number of days remaining in the year and displays the information for the user.
- Your program must print an error message and exit if any information entered is invalid.
- Consider using additional functions that prompt the user for input.
Due 1:30PM - Friday, February 9, 2007
- Complete and submit your working code. Turn in a hard copy in class and place a copy of your .py file in the submit directory /home/submit/cs110-s07/username.
- Make sure that each function is well documented. Your documentation should specify the type and function of the input parameters and output.
- Run your program on a variety of inputs ensuring that all error conditions are handled correctly.
Note: No portion of your code may be copied from any other
source including another text book, a web page, or another
student (current or former). You must provide citations for any
sources you have used in designing and implementing your program.
Sami Rollins