25.03.2013 Views

Copyright Sams Teach Yourself Shell Programming in 24 Hours

Copyright Sams Teach Yourself Shell Programming in 24 Hours

Copyright Sams Teach Yourself Shell Programming in 24 Hours

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

B:amount<br />

Here amount is the balance amount <strong>in</strong> the account.<br />

For the purposes of this problem, you need to be concerned with the first field, which conta<strong>in</strong>s the<br />

command; the second field, which conta<strong>in</strong>s the transaction date; and the last field, which conta<strong>in</strong>s<br />

the transaction amount.<br />

The sample <strong>in</strong>put file looks like the follow<strong>in</strong>g:<br />

$ cat account.txt<br />

account.txt<br />

B:0<br />

D:10/<strong>24</strong>/97:<strong>in</strong>ital deposit:1000<br />

C:10/25/97:credit card:101:100<br />

W:10/30/97:gas:21.43<br />

W:10/30/97:lunch:11.34<br />

C:11/02/97:toner:41.45<br />

C:11/04/97:car payment:347.23<br />

D:11/06/97:dividend:687.34<br />

W:11/10/97:emergency cash:200<br />

Your output should look like the follow<strong>in</strong>g:<br />

10/<strong>24</strong>/97 1000.00<br />

10/25/97 900.00<br />

10/30/97 878.57<br />

10/30/97 867.23<br />

11/02/97 825.78<br />

11/04/97 478.55<br />

11/06/97 1165.89<br />

11/10/97 965.89<br />

3. Modify the program you wrote for question 2 to pr<strong>in</strong>t the end<strong>in</strong>g (total) balance after all <strong>in</strong>put<br />

records have been considered. Your output should now look like the follow<strong>in</strong>g:<br />

10/<strong>24</strong>/97 1000.00<br />

10/25/97 900.00<br />

10/30/97 878.57<br />

10/30/97 867.23<br />

11/02/97 825.78<br />

11/04/97 478.55<br />

11/06/97 1165.89<br />

11/10/97 965.89<br />

-<br />

Total 965.89<br />

(HINT: Use the END pattern)<br />

4. Modify the program you wrote <strong>in</strong> question 3 to support a new command:

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!