Page 1 of 1

Writing Scheme functions with decisions (using 'if' or 'cond') Here is my code

Posted: Tue Apr 26, 2022 7:40 pm
by answerhappygod
Writing Scheme functions with decisions (using 'if' or
'cond')
Writing Scheme Functions With Decisions Using If Or Cond Here Is My Code 1
Writing Scheme Functions With Decisions Using If Or Cond Here Is My Code 1 (56.49 KiB) Viewed 37 times
Here is my code
Writing Scheme Functions With Decisions Using If Or Cond Here Is My Code 2
Writing Scheme Functions With Decisions Using If Or Cond Here Is My Code 2 (107.64 KiB) Viewed 37 times
(3) Write a function called PayCheck used to compute the total weekly pay check of an employee at Knaechelkopf's department store. (a) Employees are either hourly or paid by commission. (b) Hourly employees get their hourly rate times the number of hour 5) plus time and a half for overtime (more than 40 hours). (c) Commissioned employees get a percentage of their sales, as follo WS: sales rate s < $1000 1% $1000 S S < $10,000 2.5% s $10,000 6% (d) Every employee has the option to contribute to the boss's birthd ay fund, and the amount of the donation is subtracted from the weekly p ay [ Inputs: a boolean that indicates employee type (hourly/not hourly), a nu mber that indicates either hours or sales, a number that indicates the hourly r ate (or zero for commissioned employees), and the amount donated to the boss' birt hday gift fund (zero if no gift). ] Turn in one file called "FunWithFunctions Part2.rkt" containing all three f unctions.
JOUWN 15 19 1 2 3 (define (paycheck type num rate gift) 4 ; if hourly employee 5 (cond ((equal? type #t) (- (+ (* num rate) num (* 0.5 (- num 40))) gift)) 6 ; Commissionedd employee 7 (else (cond ((< num 1000) (- (* num 0.01) gift)) 8(< num 10000) +b num 0.025) gift)) 9 (else (- (* num 0.06)) gift) 10) 11 ) 12) 13) 14 (display "Pay 35 hours, $10 hr, no kissup ş") (Paycheck #t 35 10 0) 16 (display "Pay 45 hours, $10 hr, no kissup ş") 17 (Paycheck #t 45 10 0) 18 (display "Pay 35 hours, $10 hr, $20 kissup $") (PayCheck #t 35 10 20) 20 (display "Pay 45 hours, $10 hr, $20 kissup $") 21 (Paycheck #t 45 10 20) 22 (display "Pay $500 sales, $0 hr, no kissup $") (PayCheck #f 500 00) 24 (display "Pay $5000 sales, $0 hr, no kissup ş") 25 (Paycheck #f 5000 0 0) 26 (display "Pay $15000 sales, $0 hr, no kissup $") 27 (Paycheck #f 15000 0 0) 28 (display "Pay $500 sales, $0 hr, $20 kissup ş") 29 (PayCheck #f 500 0 20) 30 (display "Pay $5000 sales, $0 hr, $20 kissup $") 31 (Paycheck #f 5000 0 20) 32 (display "Pay $15000 sales, $0 hr, $20 kissup $") 33 (Pavcheck #f 15000 0 20) Language: R5RS; memory limit: 128 MB. Pay 35 hours, $10 hr, no kissup $382.5 Pay 45 hours, $10 hr, no kissup $497.5 Pay 35 hours, $10 hr, $20 kissup $362.5 Pay 45 hours, $10 hr, $20 kissup $477.5 Pay $500 sales, $0 hr, no kissup $5.0 Pay $5000 sales, $0 hr, no kissup $ *b: undefined; cannot reference an identifier before its definition 23