Company XYZ & Co.\ pays all its employees $12 per hour. A typical employee works between 20 and 65 hours per week. Develop a program that determines the wage of an employee from the number of hours of work.The last sentence is the first to mention the actual task: to write a program that determines one quantity based on some other quantity. More specifically, the program consumes one quantity, the number of hours of work, and produces another one, the wage in dollars. The first sentence implies how to compute the result, but doesn't state it explicitly. In this particular example, though, this poses no problem. If an employee works h hours, the wage is
Now that we have a rule, we can formulate a Scheme program:<#744#>(d<#744#><#745#>efine<#745#> <#746#>(wage<#746#> <#747#>h)<#747#>
<#748#>(*<#748#> <#749#>12<#749#> <#750#>h))<#750#>
The program is called <#60392#><#754#>wage<#754#><#60392#>; its parameter <#60393#><#755#>h<#755#><#60393#> stands for
the hours an employee works; and its result is <#60394#><#756#>(*<#756#>\ <#757#>12<#757#>\ <#758#>h)<#758#><#60394#>, the
corresponding wage.
~<#760#>Discuss with your students how they teased out what they had to do and what information was superfluous. It is impossible to give guidelines on that, but practice and discussing the idea repeatedly helps a lot. The following exercises prepare students thematically and practically for the section on ``a program = many function definitions''. Use the solutions as motivations for the section on comopsing functions.<#760#>
<#763#>Exercise 2.3.1<#763#>