HOMEWORK PROBLEM 2 INTRODUCTION TO Ada'95 586 PURPOSE: To gain experience with array structures More on Text_IO Get, Put, on various types Internal procedures in a main program structure Handling characters and enumeration types END RESULT: A complete Ada program that is a single procedure with two internal procedures that compiles and executes with no errors PROBLEM: Write an Ada program to simulate a simple bank. You may use the skeleton program bank.adb that is attached or do your own from scratch. The skeleton program may be copied from ECLUS::DISK2:[ADA.ADA95]BANK.* or FTP from sigpro.md.essd.northgrum.com/pub/ada95 or get from the floppy disk passed out in class. Each input line contains a simple bank activity: JOHN DOE OPEN 10.00 opens an account JIM JONES OPEN 37.50 opens an account JOHN DOE DEPOSIT 5.00 deposits $5 JIM JONES WITHDRAW 7.50 withdraws $7.50 JOHN DOE CLOSE 0.00 closes his account At the end of the run, print out the status of the accounts. TURN IN: Printout of source code (No compilation errors) Printout of execution for test data (in order) of the data listed above. OBSERVE: Character strings require exact match. This means quoted character constants need trailing blanks. Input data using Get on character strings also require trailing blanks (exact count!). Operating systems provide line editing, thus a carriage return is needed to commit the input. Input can be for one or more GET procedure calls. The physical location of an internal procedure or function is critical. They must be after all declarations and before the 'begin'. EXTRA CREDIT Give error message if opening an open account if closing a non open account if overdrawing, negative amounts, etc. Physically delete closed accounts to be ready for future homework assignments READING: Barnes 8.1 8.2 8.3 8.4 ISO 8652:1995 3.6 The following commands compile, link and run Homework 2 on Unix, W95, NT gcc -c bank.adb gnatbl bank.ali bank < bank.dat > bank.out print bank.adb print bank.out (If you had an Ada'83 .ada file, first do gnatchop xxx.ada, then use gnat on the resulting .adb and .ads files. Don't just rename file) The input data is (bank.dat): JOHN DOE OPEN 10.00 opens an account JIM JONES OPEN 37.50 opens an account JOHN DOE DEPOSIT 5.00 deposites $5 JIM JONES WITHDRAW 7.50 withdraws $7.50 JOHN DOE CLOSE 0.00 closes his account, takes out all his money BAD TRANS FOUL 1.00 bad transaction NOT OPEN CLOSE 1.00 bad, not open JIM JONES OPEN 15.00 no Jim, its open JIM JONES DEPOSIT -5.00 no Jim, try again, must be positive JIM JONES WITHDRAW -5.00 no Jim, positive ! JOHN DOE DEPOSITE 5.00 not open, forget it JIM JONES WITHDRAW 99.99 too much, reject Results of program as given to you are (bank.out): ENTER Transaction. Name,Transaction,Amount Name= JOHN DOE Transaction OPEN Amount = 1.00000E+01 Open ENTER Transaction. Name,Transaction,Amount Name= JIM JONES Transaction OPEN Amount = 3.75000E+01 Open ENTER Transaction. Name,Transaction,Amount Name= JOHN DOE Transaction DEPOSIT Amount = 5.00000E+00 Deposit ENTER Transaction. Name,Transaction,Amount Name= JIM JONES Transaction WITHDRAW Amount = 7.50000E+00 Withdraw ENTER Transaction. Name,Transaction,Amount Name= JOHN DOE Transaction CLOSE Amount = 0.00000E+00 Close ENTER Transaction. Name,Transaction,Amount Name= BAD TRANS BAD INPUT DATA ENTER Transaction. Name,Transaction,Amount Name= NOT OPEN Transaction CLOSE Amount = 1.00000E+00 Close ENTER Transaction. Name,Transaction,Amount Name= JIM JONES Transaction OPEN Amount = 1.50000E+01 Open Account Already Open ENTER Transaction. Name,Transaction,Amount Name= JIM JONES Transaction DEPOSIT Amount =-5.00000E+00 Deposit ENTER Transaction. Name,Transaction,Amount Name= JIM JONES Transaction WITHDRAW Amount =-5.00000E+00 Withdraw ENTER Transaction. Name,Transaction,Amount Name= JOHN DOE BAD INPUT DATA ENTER Transaction. Name,Transaction,Amount Name= JIM JONES Transaction WITHDRAW Amount = 9.99900E+01 Withdraw ENTER Transaction. Name,Transaction,Amount end of input data Bank Is Closed.