CSc 3320 System-Level Programming
Fall 1999
Homework #3
Due: 27 October 1999 (Wednesday)


  1. Write a csh script which manages a phone book. The script should be menu-based with the following options:
      (a) Add entry
      (l) Lookup entry
      (d) Delete entry
      (u) Update entry
      (p) Print phone book
      (q) Quit
    
    Each phone entry should consist of a first name, last name and a phone number. The phone entries must be kept sorted based on last name in a text file (called .phonebook) in the user's home directory with the following format:
    Larry Jones 404-666-6161
    John Smith 404-666-6162
    Tim Zand 404-666-6163
    
    The add entry option should prompt the user for first name, last name and phone number. It should check to see if the person has an entry. If yes, an error message should be displayed. Otherwise, it should make the entry in the file at the correct place. The look up entry option should prompt the user for last name and display all phone numbers that match the last name. The delete entry should prompt the user for the first and last name and delete the corresponding entry (error message should be generated if entry does not exist). The update entry option should prompt the user for first and last name and then display the old phone number (error should be reported if entry does not exist). It should prompt user for new phone number and make the change in the file. The print option should display the phone entries on the screen in a nice format. If there are lots of phone entries, you should display a screenful and ask user to hit a key to display remaining. Call this program phonebook.

  2. Write a Perl program which produces an amortization report for a loan. The program should work as follows:
    % perl amort.pl
    Enter interest rate (APR): 8.0
    Enter number of months: 36
    Enter loan amount: 8000
    The amortization report can be seen in file amort.dat
    

    The report should be sent to file amort.dat and should have the following format:

    
    AMORTIZATION REPORT
    
    Interest Rate = 8.000
    Months        = 36
    Loan Amount   = 8000.00
    Monthly Amt   = 250.70
    
      MONTH   IP     PP
    
        1   53.33  197.37
        2   52.02  198.68
        3   50.69  200.01
        4   49.36  201.34
        5   48.02  202.68
        6   46.67  204.03
        7   45.31  205.39
        8   43.94  206.76
        9   42.56  208.14
       10   41.17  209.53
       11   39.77  210.93
       12   38.37  212.33
    -------------------------------------
           551.20 2457.20
    -------------------------------------
       13   36.95  213.75
       14   35.53  215.17
       15   34.09  216.61
       16   32.65  218.05
       17   31.19  219.51
       18   29.73  220.97
       19   28.26  222.44
       20   26.78  223.92
       21   25.28  225.42
       22   23.78  226.92
       23   22.27  228.43
       24   20.74  229.96
    -------------------------------------
           898.45 5118.35
    -------------------------------------
       25   19.21  231.49
       26   17.67  233.03
       27   16.11  234.59
       28   14.55  236.15
       29   12.98  237.72
       30   11.39  239.31
       31    9.80  240.90
       32    8.19  242.51
       33    6.57  244.13
       34    4.95  245.75
       35    3.31  247.39
       36    1.66  249.04
    -------------------------------------
          1024.83 8000.37
    -------------------------------------
    
    YEARLY SUMMARY:
    
    YEAR    INT    PRIN
    ---------------------
    
     1     551.20    2457.20
     2     347.25    2661.15
     3     126.38    2882.02