5 Functions [10 marks]
Create a function that performs the following steps:
- Starts with the input variable value
address
which is the street address of the function user’s house - Doubles the value from Step 1.
- Adds
42
to the result from Step 2. - Multiplies the result from Step 3 by
50
- Subtracts the value of the input variable
birthYear
from the result from Step 4;birthYear
is the year of birth of the function user - Subtracts
50
from the result from Step 5 - Adds the value of the input variable
numBirthdays
to the result from Step 6;numBirthdays
is the number of birthdays that the function user has had this year (i.e., either0
or1
) - Subtracts
31
from the result from Step 7 - Computes the value
last
which is equal to the last two digits from Step 8; for example, if the value in Step 8 is97218
thenlast
is18
- Computes the value
first
which is equal to removing the last two digits from Step 8; for example, if the value in Step 8 is97218
thenfirst
is972
Your function should satisfy the following constraints:
- it should be named
addressAndAge
- it should return two values
first
andlast
(see Steps 9 and 10 above for details) - it should have three input values
address
,birthYear
, andnumBirthdays
(the street address, year of birth, and number of birthdays that the user has had this year)
Your function must execute the steps as described above to compute the values first
and last
.