Project 3:
Problem Solution Solution Using Formatted Output

 

CSE 1503 Introduction to Computer Programming with FORTRAN

Section 1 & 2 Due Date: March 16, 1999

 

wpe1.jpg (2746 bytes)

PROBLEM

Suppose we have an input file of the following form. There are unknown number of input lines. A positive number means a deposit. A negative number means payment. A zero (0) means a check balance

+123
+78
0
-50
+100
+10
-120
0
-50
+150

If the number is positive, this is a deposit line. In this case, you have to call a function called Deposit. In the latter function, you have to process all information related to deposit including the file output. The same apply to a payment and check balance where you have to create two other functions called Payment and CheckBalance, respectively. 

Write a Fortran program that reads in these input lines and writes the following table into a new output file

 Check Book Reference Listing
 ============================

 Count   Payment   Deposit   Balance
 -----   -------   -------   -------
     1   *******       123       123
     2   *******        78       201
 -----------------------------------
     3         0       201       201
 -----------------------------------
     4        50   *******       151
     5   *******       100       251
     6   *******        10       261
     7       120   *******       141
 -----------------------------------
     8       170       311       141
 -----------------------------------
     9        50   *******        91
    10   *******       150       241
 -----------------------------------
 Total       220       461       241

The above table has four columns:

  1. The first column prints the transaction numbers
  2. The second column contains the payment amount. It should contain the amount of payment if that transaction is a payment line, otherwise, it should contain *******
  3. The third column contains the deposit amount. It should contain the amount of deposit if that transaction is a deposit line, otherwise, it should contain *******.
  4. The fourth column contains the balance after each transaction is made

If the input line is zero (0), then your program should print a dashed line, followed by the total payment and total deposit up to this point, and the current balance, followed by another dashed line. 

At the end of the report, a dashed line followed by the total payment, total deposit and current balance must be printed. 

NOTES
 
 

  • Include the required header comments and indenting. A suggested style for the header comments is:
PROGRAM BankStatement
!---------------------------------------------------------------------------
! Name: (your name)
! Student ID # : (your id)
!
! (description of the program) 
! Input Variables: (variables list)
! Output Variables: (variables list)
!---------------------------------------------------------------------------
      
IMPLICIT NONE
(program statements)

CONTAINS

        FUNCTION Deposit(possible_arguments)
        (function statements)
        END FUNCTION DEPOSIT
        FUNCTION Payment(possible_arguments)
        (function statements)
        END FUNCTION PAYMENT
        FUNCTION CheckBalance(possible_arguments)
        (function statements)
        END FUNCTION CheckBalance
END PROGRAM BankStatement
  • Hand in a printout of your source code in class