[ create a new paste ] login | about

Project: programmingpraxis
Link: http://programmingpraxis.codepad.org/6PigWYys    [ 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 nl #\newline)

(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)))
    (for-each display `(                                                    ,nl
      "Bid for " ,composition " wall"                                       ,nl
      "Materials"                                                           ,nl
      "    Length in feet           "         ,(format "~4d" wall-length)   ,nl
      "    Height in feet           "         ,(format "~4d" wall-height)   ,nl
      "    Thickness in feet        "         ,(format "~4d" wall-thick)    ,nl
      "                             -------"                                ,nl
      "        Total cubic feet     "         ,(format "~4d" cubic-feet)    ,nl
      "    Cost per cubic foot      "         ,(format "~7,2f" cube-cost)   ,nl
      "                             -------"                                ,nl
      "        Total material cost          " ,(format "~7,2f" materials)   ,nl
      "Labor"                                                               ,nl
      "    Crew size                "         ,(format "~4d" crew-size)     ,nl
      "    Days worked              "         ,(format "~4d" work-days)     ,nl
      "    Hours per day            "         ,(format "~4d" day-hours)     ,nl
      "                             -------"                                ,nl
      "        Total hours          "         ,(format "~4d" work-hours)    ,nl
      "    Wage rate per hour       "         ,(format "~7,2f" wage-rate)   ,nl
      "                             -------"                                ,nl
      "        Total wages          "         ,(format "~7,2f" total-wages) ,nl
      "    Fringe benefits          "         ,(format "~7,2f" benefits)    ,nl
      "                             -------"                                ,nl
      "        Total labor cost             " ,(format "~7,2f" labor)       ,nl
      "                                     -------"                        ,nl
      "Total cost                           " ,(format "~7,2f" total-cost)  ,nl
      "Markup                               " ,(format "~7,2f" markup)      ,nl
      "                                     -------"                        ,nl
      "Bid price                            " ,(format "~7,2f" bid-price)   ,nl
      "                                     =======" ,nl))))


Create a new paste based on this one