<font color='black' size='2' face='arial'><br>
<span class="Apple-style-span" style="font-size: small; "><span class="Apple-style-span" style="font-size: small; ">Hello I have a program consists of two tasks. My first task works fine. In second task I have to create a new chip as soon as the new card has been created.</span>
<div><span class="Apple-style-span" style="font-size: small; "><br>
</span></div>
<div><span class="Apple-style-span" style="font-size: small; ">I am giving you sample run for the idea</span></div>
<div><span class="Apple-style-span" style="font-size: small; "><br>
</span></div>
<div><span class="Apple-style-span" style="font-size: small; ">
<div>==> (define c1 (a-chip))</div>
<div>c1</div>
<div>==> (contents c1)</div>
<div>0</div>
<div>==> (charge c1 10.00)</div>
<div>done</div>
<div>==> (contents c1)</div>
<div>10.0</div>
<div>==> (discharge c1 9.34)</div>
<div>9.34</div>
<div>==> (contents c1)</div>
<div>0.66</div>
<div>==> (discharge c1 0.67)</div>
<div>no</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>
<div><br>
</div>
<div>==> (define alan (a-card 432776 1904))</div>
<div>alan</div>
<div>==> (define bill (a-card 1 95))</div>
<div>bill</div>
<div>==> (inserted bill 96)</div>
<div>no</div>
<div>==> (contents bill) // HAVING PROBLEM IN THIS</div>
<div>ERROR: Not inserted</div>
<div>==> (inserted bill 95)</div>
<div>done</div>
<div>==> (contents bill)<span class="Apple-tab-span" style="white-space: pre; "> </span>//PROBLEM IN THIS</div>
<div>0</div>
<div>==> (free bill)</div>
<div>done</div>
<div>==> (new-pin bill 96)</div>
<div>no</div>
<div>==> (inserted bill 95)</div>
<div>done</div>
<div>==> (new-pin bill 96)</div>
<div>done</div>
<div>==> (account-number bill)</div>
<div>1</div>
<div>==> (free bill)</div>
<div>done</div>
<div>==> (account-number bill)</div>
<div>1</div>
</div>
<div><br>
</div>
<div>I AM NOT ABLE TO WORK OUT CONTENTS IN TASK 2..</div>
<div>I have already created contents in task 1. Do I have to create it again.</div>
<div><br>
</div>
<div>let me summarise my problem- </div>
<div>when I write (contents card) it has to work all the three procedures defined in task one contents, charge and discharge.</div>
<div>I have given some efforts but don't worth it.</div>
<div><br>
</div>
<div>Any help will be appreciated</div>
<div>thanks</div>
<div><br>
</div>
</span>
<div><span class="Apple-style-span" style="font-size: small; ">;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;TASK 1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</span></div>
<div><span class="Apple-style-span" style="font-size: small; "><br>
</span></div>
<div><span class="Apple-style-span" style="font-size: small; ">(define (a-chip)</span></div>
<div><span class="Apple-style-span" style="font-size: small; "><br>
</span></div>
<div><span class="Apple-style-span" style="font-size: small; "> (let ( (balance 0) )</span></div>
<div><span class="Apple-style-span" style="font-size: small; "> (define (the-chip op)</span></div>
<div><span class="Apple-tab-span" style="white-space: pre; "><span class="Apple-style-span" style="font-size: small; "> </span></span><span class="Apple-style-span" style="font-size: small; ">(sequence</span></div>
<div><span class="Apple-style-span" style="font-size: small; "> (cond ((eq? op 'contents) (lambda () balance))</span></div>
<div><span class="Apple-style-span" style="font-size: small; "> ((eq? op 'charge) charge)</span></div>
<div><span class="Apple-style-span" style="font-size: small; "> ((eq? op 'discharge) discharge)</span></div>
<div><span class="Apple-style-span" style="font-size: small; "> (else (error "chip: unknown operation" op))</span></div>
<div><span class="Apple-style-span" style="font-size: small; "> )</span></div>
<div><span class="Apple-tab-span" style="white-space: pre; "><span class="Apple-style-span" style="font-size: small; "> </span></span><span class="Apple-style-span" style="font-size: small; ">'nononon)</span></div>
<div><span class="Apple-style-span" style="font-size: small; "> )</span></div>
<div><span class="Apple-style-span" style="font-size: small; "><br>
</span></div>
<div><span class="Apple-style-span" style="font-size: small; "> (define (charge amount)</span></div>
<div><span class="Apple-style-span" style="font-size: small; "> (set! balance amount)</span></div>
<div><span class="Apple-tab-span" style="white-space: pre; "><span class="Apple-style-span" style="font-size: small; "> </span></span><span class="Apple-style-span" style="font-size: small; ">'done</span></div>
<div><span class="Apple-tab-span" style="white-space: pre; "><span class="Apple-style-span" style="font-size: small; "> </span></span></div>
<div><span class="Apple-tab-span" style="white-space: pre; "><span class="Apple-style-span" style="font-size: small; "> </span></span></div>
<div><span class="Apple-style-span" style="font-size: small; "> )</span></div>
<div><span class="Apple-style-span" style="font-size: small; "><br>
</span></div>
<div><span class="Apple-style-span" style="font-size: small; "> (define (discharge amount)</span></div>
<div><span class="Apple-style-span" style="font-size: small; "> (if (> (- balance amount) 0)</span></div>
<div><span class="Apple-tab-span" style="white-space: pre; "><span class="Apple-style-span" style="font-size: small; "> </span></span><span class="Apple-style-span" style="font-size: small; ">( sequence (set! balance (- balance amount))</span></div>
<div><span class="Apple-tab-span" style="white-space: pre; "><span class="Apple-style-span" style="font-size: small; "> </span></span></div>
<div><span class="Apple-tab-span" style="white-space: pre; "><span class="Apple-style-span" style="font-size: small; "> </span></span><span class="Apple-style-span" style="font-size: small; ">amount)</span></div>
<div><span class="Apple-style-span" style="font-size: small; "> </span><span class="Apple-tab-span" style="white-space: pre; "><span class="Apple-style-span" style="font-size: small; "> </span></span><span class="Apple-style-span" style="font-size: small; ">'no</span></div>
<div><span class="Apple-tab-span" style="white-space: pre; "><span class="Apple-style-span" style="font-size: small; "> </span></span><span class="Apple-style-span" style="font-size: small; ">)</span></div>
<div><span class="Apple-style-span" style="font-size: small; "> )</span></div>
<div><span class="Apple-style-span" style="font-size: small; "><br>
</span></div>
<div><span class="Apple-style-span" style="font-size: small; "> the-chip</span></div>
<div><span class="Apple-style-span" style="font-size: small; "> )</span></div>
<div><span class="Apple-tab-span" style="white-space: pre; "><span class="Apple-style-span" style="font-size: small; "> </span></span><span class="Apple-style-span" style="font-size: small; ">"mjuu"</span><span class="Apple-tab-span" style="white-space: pre; "><span class="Apple-style-span" style="font-size: small; "> </span></span></div>
<div><span class="Apple-style-span" style="font-size: small; "><br>
</span></div>
<div><span class="Apple-style-span" style="font-size: small; ">)</span></div>
<div><span class="Apple-style-span" style="font-size: small; "><br>
</span></div>
<div><span class="Apple-style-span" style="font-size: small; "><br>
</span></div>
<div><span class="Apple-style-span" style="font-size: small; "><br>
</span></div>
<div><span class="Apple-style-span" style="font-size: small; ">(define (charge chip amount) ((chip 'charge) amount))</span></div>
<div><span class="Apple-style-span" style="font-size: small; ">(define (discharge chip amount) ((chip 'discharge) amount))</span></div>
<div><span class="Apple-style-span" style="font-size: small; "><br>
</span></div>
<div><span class="Apple-style-span" style="font-size: small; ">(define (contents chip) ((chip 'contents) ))</span></div>
<div><span class="Apple-style-span" style="font-size: small; "><br>
</span></div>
<div><span class="Apple-style-span" style="font-size: small; "><br>
</span></div>
<div><span class="Apple-style-span" style="font-size: small; ">
<div>;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;TASK 2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;</div>
<div><br>
</div>
<div><br>
</div>
<div>(define (a-card account tpin)</div>
<div><span class="Apple-tab-span" style="white-space: pre; "> </span>( let ( (chip #f))</div>
<div><span class="Apple-tab-span" style="white-space: pre; "> </span> (define (the-card request)</div>
<div><span class="Apple-tab-span" style="white-space: pre; "> </span>(cond ((eq? request 'inserted)<span class="Apple-tab-span" style="white-space: pre; "> </span>inserted)</div>
<div><span class="Apple-tab-span" style="white-space: pre; "> </span> ((eq? request 'free)<span class="Apple-tab-span" style="white-space: pre; "> </span> free)</div>
<div><span class="Apple-tab-span" style="white-space: pre; "> </span> ((eq? request 'new-pin)<span class="Apple-tab-span" style="white-space: pre; "> </span>new-pin)</div>
<div><span class="Apple-tab-span" style="white-space: pre; "> </span> ((eq? request 'account)<span class="Apple-tab-span" style="white-space: pre; "> </span>( lambda () account))</div>
<div><span class="Apple-tab-span" style="white-space: pre; "> </span><span class="Apple-tab-span" style="white-space: pre; "> </span> (else (error "card: unknown operation" request))</div>
<div><span class="Apple-tab-span" style="white-space: pre; "> </span>)</div>
<div>)</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div>(define (inserted pin )</div>
<div><span class="Apple-tab-span" style="white-space: pre; "> </span>(if (= pin tpin)</div>
<div><span class="Apple-tab-span" style="white-space: pre; "> </span>(sequence (set! chip #t)</div>
<div><span class="Apple-tab-span" style="white-space: pre; "> </span></div>
<div><span class="Apple-tab-span" style="white-space: pre; "> </span>)</div>
<div><span class="Apple-tab-span" style="white-space: pre; "> </span></div>
<div><span class="Apple-tab-span" style="white-space: pre; "> </span></div>
<div><span class="Apple-tab-span" style="white-space: pre; "> </span>'done)<span class="Apple-tab-span" style="white-space: pre; "> </span></div>
<div><span class="Apple-tab-span" style="white-space: pre; "> </span>'no))</div>
<div><br>
</div>
<div>(define (free)</div>
<div><span class="Apple-tab-span" style="white-space: pre; "> </span>(sequence (set! chip #f)</div>
<div><span class="Apple-tab-span" style="white-space: pre; "> </span>'done)</div>
<div><span class="Apple-tab-span" style="white-space: pre; "> </span>)</div>
<div><br>
</div>
<div><br>
</div>
<div>(define (new-pin new)</div>
<div><span class="Apple-tab-span" style="white-space: pre; "> </span>(if (eq? #t chip )</div>
<div><span class="Apple-tab-span" style="white-space: pre; "> </span>(sequence (set! tpin new )</div>
<div><span class="Apple-tab-span" style="white-space: pre; "> </span>'done)</div>
<div><span class="Apple-tab-span" style="white-space: pre; "> </span>'no)</div>
<div>)</div>
<div><span class="Apple-tab-span" style="white-space: pre; "> </span></div>
<div><span class="Apple-tab-span" style="white-space: pre; "> </span></div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><br>
</div>
<div><span class="Apple-tab-span" style="white-space: pre; "> </span>the-card</div>
<div><span class="Apple-tab-span" style="white-space: pre; "> </span>)</div>
<div> )</div>
<div><br>
</div>
<div><br>
</div>
<div>(define (contents card)<span class="Apple-tab-span" style="white-space: pre; "> </span>((card 'contents)))</div>
<div>(define (pupu card)<span class="Apple-tab-span" style="white-space: pre; "> </span>((card 'pupu)))</div>
<div>(define (inserted card pin)<span class="Apple-tab-span" style="white-space: pre; "> </span>((card 'inserted ) pin))</div>
<div>(define (free card)<span class="Apple-tab-span" style="white-space: pre; "> </span>((card 'free)))</div>
<div>(define (new-pin card new)<span class="Apple-tab-span" style="white-space: pre; "> </span>((card 'new-pin) new))</div>
<div>(define (account-number card)<span class="Apple-tab-span" style="white-space: pre; "> </span>((card 'account)))</div>
<div><br>
</div>
</span></div>
</div>
</span>
<div style="clear:both"></div>
</font>