a05 - CS 135 Fall 2011 Becker Goldberg Kaplan Tompkins...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CS 135 Fall 2011 Becker, Goldberg, Kaplan, Tompkins, Vasiga Assignment: 5 Due: Tuesday, October 18, 2011 9:00 pm Language level: Beginning Student with List Abbreviations (Added: Oct 13/11) Allowed recursion: Pure structural Files to submit: change.rkt , participation.rkt , convert-list.rkt , cards.rkt Warmup exercises: HtDP 10.1.4, 10.1.5, 11.2.1, 11.2.2, 11.4.3, 11.5.1, 11.5.2, 11.5.3 Practice exercises: HtDP 10.1.6, 10.1.8, 10.2.4, 10.2.6, 10.2.9, 11.4.5, 11.4.7 Here are the assignment questions you need to submit. 1. For this question, place your solution in the file change.rkt . (a) Write the function pocket-change , which consumes a list of symbols and produces a number which is the total amount of change. The symbols which have values are penny (worth $0.01 each) nickel (worth $0.05 each) dime (worth $0.1 each) quarter (worth $0.25 each) loonie (worth $1.00 each) toonie (worth $2.00 each) Any other symbol has zero value. Note: your output does not need to have two decimal places (i.e., outputs of 1.2 or 6 are acceptable, rather than 1.20 or 6.00 ). (b) Write the data definition for Coin and structure definition for coin . A coin has a name which is a symbol, and a value which is a non-negative number. (c) Write the template (as a comment in DrRacket) for functions which consume a coin . (d) Write the function strange-currency , which consumes two lists: the first list is a ( listof Coin ), and the second list is a list of symbols. The first list is used to determine the names and values of the coins, and the second list contains the names of the coins. Note that the names of the coins may be something other than penny , dime or any other previously defined coin. The function strange-currency produces the total value of the currency in the second list. As described in part (a), if a symbol in the second list is not present in any structure in the first list, that symbol has zero value. Hint: you will need a helper function....
View Full Document

This note was uploaded on 10/27/2011 for the course CS 135 taught by Professor Vasiga during the Fall '07 term at Waterloo.

Page1 / 4

a05 - CS 135 Fall 2011 Becker Goldberg Kaplan Tompkins...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online