[ create a new paste ] login | about

Project: programmingpraxis
Link: http://programmingpraxis.codepad.org/F8sO8tLO    [ raw code | fork ]

programmingpraxis - Scheme, pasted on Oct 14:
; the wall

(define (get parm)
  (display (case parm
    ((composition) "Enter type of wall in quotes (for instance, \"Lava Rock\" or \"Brick\")")
    ((wall-length) "Enter length of wall in whole feet (for instance, 20)")
    ((wall-height) "Enter height of wall in whole feet (for instance, 6)")
    ((wall-thick)  "Enter thickness of wall in whole feet (for instance, 2)")
    ((cube-cost)   "Enter cost per cubic foot in dollars (for instance, 3 or 2)")
    ((crew-size)   "Enter number of workmen in crew (for instance, 2)")
    ((work-days)   "Enter number of days worked (for instance, 3)")
    ((day-hours)   "Enter number of hours per day (for instance, 8)")
    ((wage-rate)   "Enter wage rate in dollars per hour (for instance, 10)")
    ((fringe-pcnt) "Enter benefits rate as a percent (for instance, 20)")
    ((margin)      "Enter markup rate as a percent (for instance, 30)")
    (else (error 'get "unrecognized parameter"))))
  (display ": ") (read))

(define (wall)
  (let* ((composition (get 'composition))
         (wall-length (get 'wall-length))
         (wall-height (get 'wall-height))
         (wall-thick (get 'wall-thick))
         (cubic-feet (* wall-length wall-height wall-thick))
         (cube-cost (get 'cube-cost))
         (materials (* cube-cost cubic-feet))
         (crew-size (get 'crew-size))
         (work-days (get 'work-days))
         (day-hours (get 'day-hours))
         (work-hours (* crew-size work-days day-hours))
         (wage-rate (get 'wage-rate))
         (total-wages (* work-hours wage-rate))
         (fringe-pcnt (get 'fringe-pcnt))
         (benefits (* total-wages fringe-pcnt 1/100))
         (labor (+ total-wages benefits))
         (total-cost (+ materials labor))
         (margin (get 'margin))
         (markup (* total-cost margin 1/100))
         (bid-price (+ total-cost markup)))
    (format #t "~%Bid for ~a wall~%~%" composition)
    (format #t "Materials~%")
    (format #t "    Length in feet           ~4d~%" wall-length)
    (format #t "    Height in feet           ~4d~%" wall-height)
    (format #t "    Thickness in feet        ~4d~%" wall-thick)
    (format #t "                             -------~%")
    (format #t "        Total cubic feet     ~4d~%" cubic-feet)
    (format #t "    Cost per cubic foot      ~7,2f~%" cube-cost)
    (format #t "                             -------~%")
    (format #t "        Total material cost          ~7,2f~%~%" materials)
    (format #t "Labor~%")
    (format #t "    Crew size                ~4d~%" crew-size)
    (format #t "    Days worked              ~4d~%" work-days)
    (format #t "    Hours per day            ~4d~%" day-hours)
    (format #t "                             -------~%")
    (format #t "        Total hours          ~4d~%" work-hours)
    (format #t "    Wage rate per hour       ~7,2f~%" wage-rate)
    (format #t "                             -------~%")
    (format #t "        Total wages          ~7,2f~%" total-wages)
    (format #t "    Fringe benefits          ~7,2f~%" benefits)
    (format #t "                             -------~%")
    (format #t "        Total labor cost             ~7,2f~%" labor)
    (format #t "                                     -------~%")
    (format #t "Total cost                           ~7,2f~%" total-cost)
    (format #t "Markup                               ~7,2f~%" markup)
    (format #t "                                     -------~%")
    (format #t "Bid price                            ~7,2f~%" bid-price)
    (format #t "                                     =======~%")))


Create a new paste based on this one