| |||||||||||
| |||||||||||
A Perl practical on ladder lengths
![]()
An exercise set during on our Perl Programming course, when we're asking our
trainees to write a subroutine. A young gentleman in Verona wishes to take a
young lady out one evening, but her parents don't approve of the match. She
lives in a castle set on a rocky outcrop, which is 12 metres tall and there's
a convenient spot to rest the base of a ladder 5 metres away from the outcrop.
Once onto the castle mound, the young gent (shall we call him Romeo?) needs a
further ladder to reach the window of his beloved (she's called Juliet), which
is a further 4 metres up. He can't get the ladder close, though, as there's
a three metre wide rosebed and he has to put the ladder outside that. Write
a Perl subroutine to calculate ladder lengths given the height and distance
from the wall in each case, and write a piece of test code that makes two calls
to this subroutine to work out the ladder lengths needed.
Show a large image More about this subject Associated topic - Subroutines in Perl |
| ||||||||||
PH: 0800 043 8225 or 01225 708225 • FAX: 0845 8382 405 or 01225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho | |||||||||||