CS 1101 - Aterm 08
Homework 3 - Mixed Data
Due: Friday, September 12 at 11:59pm
Read the expectations on homework.
Assignment Goals
- To make sure you can define mixed data
- To make sure you can write programs over mixed data
The Assignment
The college bookstore carries items that are sold under one of three categories:
books, clothing, and sundries. You will define data and write
programs that manage the inventory of bookstore items.
- book each book has a title and an author, whether or not it is a hardcover,
and whether or not it is used. Also recorded are
the number remaining in inventory, and the
cost.
- clothing is inventoried by the type (tshirt, sweatshirt,
hat, etc.), the size (XS, S, M, L, XL), the color, the number remaining in inventory, and the cost.
- sundries the attributes recorded for sundries are the
type (deoderant, shampoo, keychain, picture frame,
etc.), the number remaining in inventory, and the cost.
Writing Programs for Mixed Data
- Develop a data definition for bookstore items that covers all types of
items described above (you will need to make multiple data definitions).
Provide examples of bookstore items.
- Provide the template for each data definition you made in Problem 1.
-
Write a function
cost-of-item that consumes a bookstore item and
returns the
cost of the item. If the item is a book, and the book is used, then the
cost is reduced by 20%.
- Write a function
sale-item? that consumes a bookstore item
and returns true if that item is included in the bookstore's annual sale.
Sale items are any books that are not hardcover, and any clothing item in
size XS or S.
- Write a function
update-inventory that consumes a
bookstore item and the quantity of those items purchased, and produces a
bookstore item. The item produced is the
same as the original, except that the number remaining in the inventory is
reduced by the number purchased.
What to Turn In
Using web-based turnin,
turn in a single file hw3.scm containing
all code and documentation for this assignment. Make sure both partners' names and login names appear at the top of the file in a comment.