The Scheme Programming Language

Paycheck Calculation Example Program

Click below to go directly to a specific section:
Description| Source Code| Program Notes


This program figures your paycheck...and that's what it's all about!! It also demonstrates the concept of abstraction in Scheme. The procedure "calc-pay" in turn calls the methods by which the employee's wages and commissions are calculated. It should be noted that the functions "commissions" and "hourly-wages" are actually passed as arguments to their calling function.

Source Code

; Paycheck
; By Jerry Smith
;;;;;;   commission   ;;;;;;
(define  commission
  (lambda (sales commission-rate)
       (* sales commission-rate)))
;;;;;;;   hourly wages   ;;;;;
(define hourly-wages
  (lambda (no-hours hourly-rate)
    (if (<= no-hours 40)
          (* no-hours hourly-rate)
          (+(* 40 hourly-rate)
           (*(- no-hours 40)

;;;;;;;;;;;;;;   calc-pay   ;;;;;;;
  (define calc-pay
      (lambda (formula base rate)
      (formula base rate)))

A sample run would resemble the following: 

[1](commission 100 .04)
[2](hourly-wages 50 10)
[3](calc-pay commission 100 .04)
[4](calc-pay hourly-wages 50 10)

Program Notes

This program was found in "An Introduction to Scheme" by Jerry Smith, Prentice Hall, 1988
[Back] [Home]

Last modified: 11:30 PM on 10/13/1999