Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- COMSC-110
- Teacher
- 1. Objective: calculate how many days old you will be on the due date for this lab.
- 2. Requirements:
- --INPUT:
- DOB = "July 20, 1994"
- dueDate = "September 7, 2014"
- yearsOld = 21 (including the current year)
- --PROCESSING:
- days = 0
- leapYears = yearsOld / 4
- julianBirthdate = sum of all the days in each month up to month and date of birth
- julianDuedate = sum of all days in each month up to month and date of due date
- daysToEndOfYear = 365 - julianDuedate
- days = days * (365 * yearsOld)
- days = days + leapYears
- days = days - julianBirthdate
- days = days - daysToEndOfYear
- --OUTPUT:
- objective
- author
- user instructions (if any)
- label1 "Date of birth: "
- label2 "Due date: "
- label3 "Age in days: "
- --DATA:
- days-->>total number of days old you are on the date this lab is due (integer)
- yearsOld-->>number of years old you are (integer)
- leapYears-->>number of leap years from your birth year to this year (integer)
- julianBirthdate-->>number of days up to and including your birthday in your birthyear (integer)
- daysToEndOfYear-->>number of days from lab due date until the end of the year (integer)
- julianDuedate-->>number of days up to due date (integer)
- DOB-->>date of birth (text)
- dueDate-->>date lab is due (text)
- 3. Algorithm Instructions
- 10 output objective
- 20 output author
- 30 days = 0
- 40 yearsOld = 21
- 50 leapYears = yearsOld / 4
- 60 julianBirthdate = sum of all the days in each month up to month and date of birth
- 70 DOB = "July 20, 1994"
- 80 dueDate = "September 7, 2014"
- 90 julianDuedate = sum of all the days in each month up to month and date of due date
- 100 daysToEndOfYear = 365 - julianBirthdate
- 110 days = days + (365 * yearsOld)
- 120 days = days + leapYears
- 130 days = days - julianBirthdate
- 140 days = days - daysToEndOfYear
- 150 output label1
- 160 output DOB
- 170 output label2
- 180 output dueDate
- 190 output label3
- 200 output days
- 210 END
- 4. Test cases
- Test Case #1: DOB = 7/20/1994, dueDate = 9/7/2014
- 10 calculate how many days old you will be on the due date for this lab.
- 20 author: Teacher
- 30 days = 0
- 40 yearsOld = 21
- 50 leapYears = 20 / 4 = 5
- 60 julianBirthdate = 201
- 70 DOB = "July 20, 1994"
- 80 dueDate = "September 7, 2014"
- 90 julianDuedate = 250
- 100 daysToEndOfYear = 365 - 250 = 115
- 110 days = 0 + 7665 = 7665
- 120 days = 7665 + 5 = 7670
- 130 days = 7670 - 201 = 7469
- 140 days = 7469 - 115 = 7354
- 150 Date of birth:
- 160 July 20, 1994
- 170 Due date:
- 180 September 7, 2014
- 190 Age in days:
- 200 7354
- 210 DONE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement