Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Project Description: Write a program that accepts a date in the form month/day/year and outputs whether or not the date is valid. For example: 5/24/1962

image text in transcribed
image text in transcribed
Project Description: Write a program that accepts a date in the form month/day/year and outputs whether or not the date is valid. For example: 5/24/1962 is valid, but 9/31/2000 is not. (September has only 30 days.) Give special consideration to leap years: 2/29/2023 is not valid but 2/29/2024 is valid. A year is a leapi year if it 15 divisible by 4 , unless it is a century year that is not divisible by 400 . (1800 and 1900 are not leap years while 1600 and 2000 are.) Make sure your program correctly handles leap years and other years from years 1700 to 2200 . Also make sure that you program handles correctly the misging 11 days in the Julian calendar for 1752 (See Sample Output 4 on the next page). Reference: https://www, timeanddate, com/calendar/julian-gregorian-switeh. htm1 Requirements : 1. Use easy to understand input and output. 2. Use variable names which are reflective of their meanlng. 3. Use named constants if helpful. 4. Use a sufficient number of comments to make your code understandable. 5. Run a sufficient number of sample cases to confirm that you program is working. Compare to online calendar programs as needed. Check List and Grading Points (Rubric) : 1. Name your file fileprefixproject01,py, (1 point) 2. Include a header comment block at the top of your file. (1 point) - Name: (your name) - Course: cs 1160 * Assignment: Project 01 - Date Assigned: 1/25/2023 - Filename: filepreflxproject01a.py * Brief Description: Validating Calendar Dates 3. Use meaningful variable names. (2 points) 4. Correot, efficient and understandable use of selection structures (10 point) 5. Output agrees with Sample Outputs and follows the instructions in the problem statement. (10 point) 6. Copy your input and four sample Outputs to the bottom of your file using block triple apostrophes and submit txt file (1 point) Starter Code: date = input('Enter date as month/day/year (e.g. 04/19/2022): ) month = int (date [0:2]; get month from string positions 0,1 day = int ( date [3:51) \# get day from string positions 3,4 year = int (date (6:101) \& get year from string positions 6,7,8,9 Note on Starter Code: The code above for obtaining the integer month, day, and year from the date sthing 15 called "string slicing" and is explained on page 415 of the text. Sample string and position numbering: 04/19/2022.0123456789date[start:end)-.Containssubstringstartingatposition-.Contentsofthedatestringoflength10,-Positions2and5aretobeavoidedastheywillnotconverttoanintegervalue.Stringindexcountstartsat0andendsatonelessthanthetotallengthofthestring."start"andendingatposition"end"minus1 Here are the four Sample Outputs in your py and txt file hat the end. Note: user input is in bold. Sample Output 1: Enter date as month/day/year (e.g. 02/19/2022):04/31/2024 04/31/2024 is not a valid date. 2024 is a leap year. Sample Output 2: Enter date as month/day/year (e.g. 02/19/2022):02/29/2024 02/29/2024 is a valid date. 2024 is a leap year. Sample Output 3 : Enter date as month/day/year (e.g. 02/19/2022):02/28/2000 02/28/2000 is a valid date. 2000 is not a leap year. Sample Output 4: Enter date as month/day/year (e.g. 02/19/2022)=09/10/1752 09/07/1752 is not a valid date. 1752 is a leap year

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions