ISCG 5235 Introductory Programming

TEXT BASED USER INTERFACES Exercise 1

Create a folder under your f:\ip folder called figures. This folder names the package.

Copy the files Rectangle.java, RectangleExample.java and RectangleTUI.java from Blackboard into this folder. These 3 files belong to the figures package. This is shown by the statement:

package figures;

at the top of each program in the package (NOTE: Chapter 9 of the book covers packages)

Open the files and compile them.

Run the application. Which file runs the application?

Exercise 2

Create a folder called Bank.

Copy the file BankAccount.java from BlackBoard into this folder.

Create a Text Based User Interface for the system by creating a new file called BankAccountTUI.java that functions as follows:

When the program starts:

The user should be prompted for an Opening Balance:

Enter Opening Balance ( 0.00):

If a valid non-negative and non-zero amount is entered, a new bank account should be created.

The following menu should be displayed:

MAIN MENU

Deposit

Withdraw

View Balance

Add Interest

Create new Bank Account

Exit

Enter choice:

When option 1 is selected:

User should be prompted for a deposit amount greater than 0.00

This amount should be validated to be a valid real number greater than 0.00

The deposit method should be called

The new balance should be displayed formatted to 2 decimal places in a width of 10 and right aligned

When option 2 is selected:

User should be prompted for a withdrawal amount greater than 0.00

This amount should be validated to be a valid real number greater than 0.00

The withdraw method should be called

The new balance should be displayed formatted to 2 decimal places in a width of 10 and right aligned

When option 3 is selected:

The getBalance method should be called

The balance should be displayed formatted to 2 decimal places in a width of 10 and right aligned

When option 4 is selected:

The addInterest method should be called

The new balance should be displayed formatted to 2 decimal places in a width of 10 and right aligned

When option 5 is selected:

The user should be prompted for an Opening Balance:

Enter Opening Balance ( 0.00):

If a valid non-negative and non-zero amount is entered, a new bank account should be created.

When option 6 is selected:

The following message should be output:

Thank you for using the Bank Account System.

Create another file called BankStart.java that defines a class that only contains the main method to start the application.

TESTING AND DEBUGGING Exercise 1

Create a folder under your f:\ip folder called Bank.

Copy the files BankAccount.java, BankStart.java and BankTUI.java from BlackBoard into this folder.

Compile the files and run the program.

Test the program using the test plan provided in the document BankTestPlan.doc. Some errors have been introduced into the program.

Find the errors and fix them.

Exercise 2

Copy the program AdderTest.java from Blackboard

Run the program. What happens (or doesn't happen)?

Use the debugging tools to find the error.

Week 7 Exercises Page 3 of 3