SHARE
TWEET

Untitled

a guest Oct 21st, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import sys
  2.  
  3. class ch7project3b():
  4.   def displayInfo():
  5.     print(" Company Name")
  6.     print("\nEnter date:")
  7.  
  8.   def getDate():
  9.     userDate = input()
  10.     return userDate
  11.  
  12.   def parseMonth(userDate):
  13.     if len(userDate) == 10:
  14.       userMonth = int(userDate[:2])
  15.     else:
  16.       userMonth = int(userDate[0])
  17.  
  18.     return userMonth
  19.  
  20.   def parseDay(userDate):
  21.     if len(userDate) == 10:
  22.       userDay = int(userDate[3:5])
  23.     else:
  24.       userDay = int(userDate[2:4])
  25.  
  26.     return userDay;
  27.  
  28.   def parseYear(userDate):
  29.     if len(userDate) == 10:
  30.       userYear = userDate[6:10]
  31.     else:
  32.       userYear = userDate[5:9]
  33.    
  34.     return userYear
  35.  
  36.   def displayDate(userDate, userMonth, userDay, userYear):
  37.     monthNames = ["Invalid month", "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"]
  38.     monthDays = [00,31,28,31,30,31,30,31,31,30,31,30,31]
  39.  
  40.     if userMonth < 1 or userMonth > 12:
  41.       print("Invalid month.")
  42.       sys.exit()
  43.  
  44.     if userDay > monthDays[userMonth] or userDay < 0:
  45.       print("Invalid day.")
  46.       sys.exit()
  47.  
  48.     print("\n\n\nThe date is: " + str(monthNames[userMonth]) + " " + str(userDay) + ", " + str(userYear))
  49.  
  50.  
  51. drive = ch7project3b
  52.  
  53. drive.displayInfo()
  54. userDate = drive.getDate()
  55. userMonth = drive.parseMonth(userDate)
  56. userDay = drive.parseDay(userDate)
  57. userYear = drive.parseYear(userDate)
  58. drive.displayDate(userDate, userMonth, userDay, userYear)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top