Site hosted by Angelfire.com: Build your free website today!
Master Menu - Links the Master Page


Columns . . . :                     Edit                        RPGMR/SRCFILE 
 SEU==>_______________________________________________________            SLIC 
 FMT H  HKeywords++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
        *************** Beginning of data ************************************* 
     H
     F*---------------------------------------------------------------------
     F*-                  Author:  Browning © 01/24/2001
     F*-     
     F*- This program will calculate the interest owed on a loan (my student 
     F*- loan in this case). UNIPAC calculates interest on a Stafford Student
     F*- loan using the following formula. 
     F*- 1. Take the Principal balance, and multiply it by the interest rate
     F*-    (in this case 8.19 percent). Take the remainder and divide it by
     F*-    the number of days in a year (they use 365.25 days). 
     F*-
     F*- 2. Using the estimated date the payment will be received, and the 
     F*-    date the last payment was received, calculate how many days
     F*-    are in the current billing cycle. 
     F*-
     F*- 3. Take the result of step 1 and multiply it by the result of step
     F*-    2 to see what the actual interest charge for the current cycle is
     F*-
     F*- This program is simple and straight forward. It demonstrates several
     F*- concepts that can be difficult to grasp by a novice programmer. 
     F*-
      *-- STUDENT LOAN INTEREST CALCULATOR
     F*ILENAME++IPEASFRLEN+LKLEN+AIDEVICE+.KEYWORDS+++++++++++++++++++++++++
     FINTEREST  CF   E             WORKSTN
     D*AME+++++++++++ETDSFROM+++TO/L+++IDC.KEYWORDS+++++++++++++++++++++++++
     D FIELDS          DS
     D  PRINBAL                       7S 2 INZ(*ZEROS)
     D  INTPAID                       6S 2 INZ(*ZEROS)
     D  DATE1                         8A   INZ(*BLANKS)
     D  DATE01                         D   DATFMT(*USA/) INZ(D'0001-01-01')
     D  DATE2                         8A   INZ(*BLANKS)
     D  DATE02                         D   DATFMT(*USA/) INZ(D'0001-01-01')
     D  CALC1                        12S 6 INZ(*ZEROS)
     D  CALC2                        12S 9 INZ(*ZEROS)
     D  NUMDAYS                       4S 0 INZ(*ZEROS)
     C*0N01FACTOR1+++++++OPCODE&EXTFACTOR2+++++++RESULT++++++++LEN++D+HILOEQ
      * Display the first screen and wait for the user to press ENTER
      * or F3 to end the program.
     C                   EXFMT     INTCHG
      * This loop will continue until the user presses F3
     C                   DOW       *IN03 = *OFF
      * Once inside the loop we want to see if the user pressed F3
     C   03              LEAVE
      * If they didn't we test the conditions of the if statement. Basically
      * we say that if *IN03 is off, Dates 1 & 2 are not blanks, and the 
      * most important variable, PRINBAL, isn't 0, execute this statement.
      * If any one of these tests fail control drops to the ELSE statement.
     C                   IF        *IN03 = *OFF AND DATE1 <> *BLANKS AND
     C                             DATE2 <> *BLANKS AND PRINBAL <> *ZEROS
      * Notice that the Variables DATE1 & DATE2 are in character format, My
      * AS/400 runs V4R2, as a result display file DDS's are able to have a 
      * true date field. So character fields are required, the following two 
      * lines take these character fields and place them into variables that
      * are defined with the date data type in ISO format. The statements
      * can be put into words like this:
      *  Take the DATEX variable the user entered from the screen in USA 
      *  format (MMDDCCYY) and MOVE it into the ISO (CCYYMMDD) defined date
      *  variable DATE0X.   
     C     *USA0         MOVE      DATE1         DATE01
     C     *USA0         MOVE      DATE2         DATE02
     C                   EVAL      CALC1 = PRINBAL * .819
     C                   EVAL (H)  CALC2 = CALC1 / 365.25
     C     DATE02        SUBDUR    DATE01        NUMDAYS:*D
      * Move the decimal over one place after calculating the interest charge
      * and half adjust the result
     C                   EVAL (H)  INTPAID = (CALC2 * NUMDAYS) / 10
      * Now we are ready to redisplay the screen with the updated INTCHG
      * field
     C                   EXFMT     INTCHG
      * Wait until the user presses ENTER and reset the Data Structure named
      * FIELDS, this will reinitialize all the variables and ready the screen
      * for another iteration.
     C                   RESET                   FIELDS
      * Check to see if the user pressed F3, if so the LEAVE statement will 
      * exit us from the *IN03 loop and control will return to the statement
      * immediately following the ENDDO statement.
     C   03              LEAVE
      * If F3 wasn't pressed redisplay the screen and start the *IN03 loop
      * over.
     C                   EXFMT     INTCHG
      * ELSE none of the above conditions were met in the initial IF statement
      * so reinitialize the the variables in the data structure just in case 
      * the user started to enter data into the variables, and after 
      * redisplaying the updated screen ITER, i.e. control returns to the 
      * *IN03 loop and the *IN03 indicator is tested again to see if the loop
      * continues or control drops to the ENDDO and the program ends.
     C                   ELSE
     C                   RESET                   FIELDS
     C                   EXFMT     INTCHG
     C                   ITER
     C                   ENDIF
     C                   ENDDO
     C                   EVAL      *INLR = *ON
     C                   RETURN


Copyright ©1998 - 2001 J. Browning - All rights reserved.
Master Menu - Links the Master Page