# [racket] exercise problem

 From: Roelof Wobben (r.wobben at home.nl) Date: Tue Feb 21 14:43:34 EST 2012 Previous message: [racket] Commercial Users of Functional Programming 2012: Call for Presentations Next message: [racket] exercise problem Messages sorted by: [date] [thread] [subject] [author]

```Hello,

I try to make this exercise :

Some credit card companies pay back a small portion of the charges a
customer makes over a year. One company returns

1.

.25% for the first \$500 of charges,

2.

.50% for the next \$1000 (that is, the portion between \$500 and \$1500),

3.

.75% for the next \$1000 (that is, the portion between \$1500 and \$2500),

4.

and 1.0% for everything above \$2500.

Thus, a customer who charges \$400 a year receives \$1.00, which is 0.25 ·
1/100 · 400, and one who charges \$1,400 a year receives \$5.75, which is
1.25 = 0.25 · 1/100 · 500 for the first \$500 and 0.50 · 1/100 · 900 =
4.50 for the next \$900.

Determine by hand the pay-backs for a customer who charged \$2000 and one
who charged \$2600.

Define the function |pay-back|, which consumes a charge amount and
computes the corresponding pay-back amount

(define (tarief4 amount)
(cond
[ ( < amount 2500)(- (* .00100 amount)2500)]
[ else ( - ( * .0100 1000) 2500)]))

(define (tarief3 amount)
(cond
[ ( < amount 2500)(- (* .0075 amount)1500)]
[ else ( - ( * .0075 1000) 1500)]))

(define (tarief2 amount)
(cond
[ ( < amount 1500)(- (* .0050 amount)500)]
[ else ( - ( * .0050 1000) 500)]))

(define (tarief1 amount)
(cond
[ (< amount 500) (* 0.025 amount)]
[ else (* 0.025 500)]
))

(define (payback amount)
(cond
[ (<= amount 500) ((tarief1 amount))]
[ (and ( <= amount 1500) (> amount 500)) (+ (tarief1
amount)(tarief2 amount))]
[ (and ( <= amount 2500) (> amount 1500)) (+ (tarief3 amount)
(tarief2 amount))]
[ else (+ (tarief4 amount)(tarief3 amount))]
))

But now I get this error message :
unsaved editor>:27:23: function call: expected a function after the open
parenthesis, but found a part in: (tarief1 amount)

When I do (tarief 1 amount) instead of ((tarief amount)) I don't get the
error message but the outcome of (payback 2600) is not right.

Anyone a tip for me ?

Roelof

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20120221/3bee3293/attachment-0001.html>
```

 Posted on the users mailing list. Previous message: [racket] Commercial Users of Functional Programming 2012: Call for Presentations Next message: [racket] exercise problem Messages sorted by: [date] [thread] [subject] [author]