Threesuns

Email the Instructor

Contact

All Semesters

Semesters

All Courses

Courses

2013Fall

08.20.12 - 12.16.12

Ruby

CSYS2853

Tuesday Thursday
04:00 PM - 05:20 PM

BankAccounts

Lab03

Objective: To work with Ruby's control structures

pastdue

Submit Your Solution

Lab03

Request a Copy of your Solution

Lab03

Requirements

BankAccount class is used10 pts
Open Accounts option opens accounts10 pts
Open account option will not allow more than 5 accounts10 pts
View accounts option shows list of open accounts10 pts
Deposit option allows deposits of a chosen amount into a selected account.10 pts
Withdraw option allows withdrawal of a chosen amount from a selected account.10 pts
Exit option terminates program10 pts
Program loops and does not stop until Exit is selected10 pts
Program display menu of choices for the user10 pts
Opened accounts are stored in an array10 pts
Total100 pts

Instructions

For this lab you will be using the BankAccount class we created in class to write a small interactive Ruby program to simulate the workings of the worlds smallest and simplest bank.

Your task is to create a Ruby program that displays a menu to the user with the following options: Open Account, List Accounts, Make Deposit, Make Withdraw, and Exit.

When the program first starts it should contain no BankAccount instances but when the user chooses option 1 Open Account the program should create a new BankAccount instance and store it in an array. Every time the user chooses this option a new account should be created and added to the array but the user should not be allowed to open more than 5 accounts. The program does not need to be persistent in that each time the program is restarted it will start with no accounts.

When the user chooses option 2 View Accounts they should be shown a list of all existing accounts including the account number, the balance, and the name on the account.

When the user chooses option 3 Make Deposit the user should be prompted for both the amount to deposit and which account they want to deposit to which will mean that the user needs to be shown a list of available accounts to choose from. When the user has entered an amount and selected an account the deposit should be made.

When the user chooses option 4 Make Withdraw the user should be again prompted for the amount and which account to withdraw from making this option almost identical to the Deposit options except that a withdraw will be performed instead of the deposit.

Finally, when the user chooses option 5 Exit the program should end. Until the user chooses option 5 Exit the program should continue to loop, taking the user back to the main menu after any option has been selected and completed.