Page 198 - Open Soource Technologies 304.indd
P. 198

Event Driven Programming



                                                                  Car
                                                                  loan


                                             Get                 Make               Display
                                            input              calculations         results


                                                    Get
                                      Get    Get
                                    amount duration  interest  Compute  Compute  Display  Display
                                                   rate    monthly  1 st month’s  headings  amounts
                                                           payment   payment

                                                     Calculate  Apply
                                                    number of  payment
                                                     months    formula
                                           Figure 8.2(b): Hierarchy Chart for the Car Loan Program.

                                        It is clear from the hierarchy chart that the top modules manipulate the
                                        modules beneath them. While the higher-level modules control the flow of the
                                        program, the lower-level modules do the actual work. By designing the top
                                        modules first, specific processing decisions can be delayed.







                           The following program uses the future value function. With the responses shown, the program
                           computes the balance in a savings account when $100 is deposited for five years at 4% interest
                           compounded quarterly. Interest is earned four times per year at the rate of 1% per interest
                           period. There will be 4 * 5, or 20, interest periods.































                          192                    LOVELY PROFESSIONAL UNIVERSITY
   193   194   195   196   197   198   199   200   201   202   203