top of page

Java

Year One Assignment:

Design a program that will allow a customer to input their current checking account balance and overdraft limit, followed by a number of financial transactions. Each transaction consists of a transaction code (char) and a transaction amount (double). The transaction code can be ‘D’ for a deposit or ‘W’ for a withdrawal or ‘Q’ to quit (no other codes are valid). Your program should add each deposit transaction amount to the balance and deduct
each withdrawal transaction amount from the balance. Before carrying out any withdrawals the program should check that there are sufficient funds (including overdraft limit) to make the withdrawal. If insufficient funds are available the program should simply print “** Insufficient funds **” and NOT modify the balance. After each transaction the program should print the balance followed by “** Overdrawn **” if the account is overdrawn. When there are no more transactions a ‘Q’ can be entered for the transaction code to signify the end of the data. Using test data balance 500 overdraft 100 followed by withdrawal 60, withdrawal 500 withdrawal 100 and finally deposit 100, the interaction SHOULD look like this
:

Enter initial account balance £: 500
Enter overdraft limit £: 100
Enter transaction type D, W, Q: W
Enter withdrawal amount £: 60
Balance £ 440.00
Enter transaction type D, W, Q: W
Enter withdrawal amount £: 500
Balance £ -60.00 ** Overdrawn **
Enter transaction type D, W, Q: W
Enter withdrawal amount £: 100
** Insufficient funds **
Balance £ -60.00 ** Overdrawn **
Enter transaction type D, W, Q: D
Enter deposit amount £: 100
Balance £ 40.00
Enter transaction type D, W, Q: Q
Thank you for using Cheque Balance Program

Programming I

posted by Niall

bottom of page