This optional programming problem provides an opportunity for a student to earn up to fifty additional points which will be added to your hour exam point total for the semester.
The problem we wish to solve is to write a program which will help us keep track of money in a checking account. We want to know both how money is spent on different expense categories (food, rent, books, etc.), and how money comes into the checking account from different sources (salary, gifts, interest, etc.). Following standard bookeeping practice, we call both expense categories and sources of income accounts.
At this point we shall leave the exact details of the program input unspecified except to say that the input data is represented as a boxed list of two element boxed lists, each representing a transaction, an account together with an amount to be added to or subtracted from the balance in that account. Each transaction has the form
+-------+------+ |account|amount| +-------+------+
Different solutions can use different ways to designate accounts, tailoring the choice to the programmer's or the user's convenience. We do specify, however, that the output should have the same form as the input and that the amount associated with each account be the sum of the amounts associated with that account in the input data.
For example, suppose we are given data such that:
open data +------+------+ |salary|275.31| +------+------+ |rent |_250 | +------+------+ |salary|125.43| +------+------+ |food |_23.59| +------+------+ |books |_60.42| +------+------+ |food |_18.07| +------+------+
the program should produce the following output summary.
open output +------+------+ |salary|400.74| +------+------+ |rent |_250 | +------+------+ |food |_41.66| +------+------+ |books |_60.42| +------+------+
In addition to developing one or more programs to accomplish this computation you should also perform an analysis of the algorithm used.
One way of setting up inputs to the program is:
data =: ('salary' ; 275.31) ; ('rent' ; _250) ; ('salary' ; 125.43) ; ('food' ; _23.59) ; ('books' ; _60.42) ; box ('food' ; _18.07)