### Section 7

Problem 1:

Use the following data and structure definitions to solve this problem.

A Document-summary is one of
``` (make-letter Symbol Symbol Symbol) (make-memo Symbol Symbol Symbol Symbol) (make-resume Symbol Symbol Boolean) ```

where

``` (define-struct letter (to date signature)) (define-struct memo (from to date subject)) (define-struct resume (name date sent?)) ```

Develop the function from, which consumes a Document-summary and produces a symbol representing the author of the document (use the `signature` property of a letter, the `from` property of a memo, and the `name` property of the resume).

Problem 2:
Develop data and structure definitions for a collection of 3D shapes. The collection includes
• cubes whose relevant property is the length of an edge;
• prisms which are rectangular solids and whose relevant properties are length, width, and height;
• spheres whose relevant property is the radius.

Develop the function volume. The function consumes a 3D shape and produces the volume of the object.

The volume of a cube is the cube of the length of one of its edges. The volume of a prism is the product of its length, width, and height. The volume of a sphere is 4/3 * PI * r3.

Problem 3:
Develop data and structure definitions for trains. A train is one of
• commuter, which has the properties: number of cars, number of passengers per car, and a boolean determing whether this particular train makes all stops;
• amtrak, which has the properties: number of cars, number of passengers per car, and a symbol designating the type of train as 'Express, 'Local, or 'Limited;
• subway, which has the properties: number of cars, number of passengers per card, and a symbol represeting the color of the train.
Develop the function hold-all? that, given a train and a number of passengers, produces `true` if the train could contain them all and `false` if not.

Problem 4:
Develop data and structure definitions for school employees. An employee is one of
• principal with properties of monthly salary, office number, and a symbol represting the diploma or degree earned by the principal;
• teacher with properties of monthly salary, room number, and a symbol represting the diploma or degree earned by the teacher;
• assistant with properties of hourly wage and number of hours worked within a pay period.

The payroll office needs to compute various taxes before printing a paycheck. Develop the function tax, which takes an employee structure and a tax rate and returns the amount of tax for the pay period (per month for principals and teachers and the hours worked for an assistant).

Problem 5:
Develop data and structure definitions for financial accounts. An account is one of
• checking with two properties: balance and number of transactions;
• savings with two properties: balance and number of transactions;
• credit with three properties: balance, spending limit, and number of transactions.

Develop a data definition for a response. A response is either 'Error or an account.

Develop the function withdrawal, which consumes an account and an amount and produces a response. In the case in which a withdrawal would cause the balance of a savings account to go below zero, 'Error would be produced. Otherwise a new savings account would be produced with a new balance and the number of transactions incremented by one. A checking account has overdraft protection up to \$1000, so a withdrawal would signal 'Error if the balance were lower than \$-1000. A credit account's balance increases upon withdrawal, but cannot go beyond the spending limit.

 Jamie Raymond Matthias Felleisen 23 september 2002
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0}