### Assignment 10: Accumulators and State (due Nov 17)

Before you tackle the homework, remind yourself of our General Advice, Advice on Homeworks, and Grading Guidelines. Above all, keep your work neat and honest.

1. (4 pts) Recall the employee hierarchy definition from the exam:
```An employee-record is a structure
(make-empnode N S P M)
where N is a symbol representing the person's name,
S is a number representing their salary,
P is a (listof symbol) naming their projects, and
M is a (listof employee-records) indicating who the person manages.

(define-struct empnode (name salary projects manage))
```

Rewrite the exam problem project-salary in accumulator style. The program should consume a symbol (a project name) and an employee-record and produce a number. The returned number should be the sum of all of the salaries of all personnel on the project.

(Note: the helper function that checks whether a project name is in a list of projects does not need to be written in accumulator style).

2. (10 pts) A local bank needs a program to manage its accounts. An account consists of a person's name, an account number, the current account balance, and the number of transactions on the account since the transactions counts were last reset. The banking system needs to be able to provide the following services:

• Add a new account given a name, account number, and initial balance.
• Record a deposit of a given amount to a given account number.
• Record a withdrawal of a given amount to a given account number.
• Lookup the balance in a given account.
• Assess excessive transaction fees too all accounts. When the bank invokes this option, every account with more than five transactions (deposits or withdrawals) should be charged two dollars for each additional transaction.
• Reset the transaction counts for all accounts. The bank can invoke this option (e.g., at the start of each month) to set the transaction counts on all accounts to zero.

Write a program that provides all of these services. Your program must hide the accounts so that the only way to modify an account is through your program. Aside from that restriction, the interface for your program is your decision.

 Kathi Fisler This page was generated on Wed Nov 10 11:30:27 CDT 1999.