Cals Begin and End Balance 
Author Message
 Cals Begin and End Balance

Hozit guys
Suppose I have a file consisting of a beggining balance and withdraws and
deposits:

Jones 1000.00 w 200.00 w 100.00 d 500.00
Smith 5000.00 w 3000.00 d 300.00 w 1000.00
Taylor 3000.00 d 3000.00 w 2500.00

I use this script to calculate the beginning and ending balance for each
person:

{print $1, "Beginning Balance Is ", $2
i=3; balance = $2
while (i <= NF) {
balance = ( ($i =="w") ? balance - $(i+1) : balance +$(i+1))
 i+=2

Quote:
}

print $1, "Ending Balance is ", balance}

Howerver I do not now how to put in error control coz if d is any other word
then the program classifies it as a debit.  Maybe multiple if and else
statements will do the trick ??



Wed, 23 Jan 2002 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Calculate ending balance & charge on overdraftw

2. prob. with BEGIN/END

3. Smalltalk on the small end (was: Advice requested: GUI project beginning)

4. /BEGIN/ .. /END/ file reading

5. How to write filesearch with begin-pattern till end-pattern

6. begin/end doesn't behave as expected

7. Braces and begin/end

8. Suggestion for addition to Begin/End syntax

9. Are begin/end blocks atomic?

10. Beginning of End of Ada Mandate

11. remove begin and end tags and its content in between

12. Is Perlish BEGIN / END possible?

 

 
Powered by phpBB® Forum Software