Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Project 3 Purpose: This program will provide experience reading and writing files. It will also provide an opportunity to practice some String operations. Project Overview

Project 3

Purpose: This program will provide experience reading and writing files. It will also provide an opportunity to practice some String operations.

Project Overview

This project consists of 2 pieces. Part 1 involves writing a program for creating and deleting bank accounts. Account information is stored in a file. An account administrator would use this program to add and delete accounts and to get a report on all existing accounts. Part 2 involves writing a program for a bank teller who must be able to get account balances, and process deposit and withdrawal transactions. Part 2 makes use of the file containing account information that was created by the program from part 1.

Project Logistics

This project will contain two separate programs within a single Netbeans project. Create your project in the usual way and completely develop and test part one in your project. Then for part two add a new Java class to your project. When created, this class will not contain a main method. You will need to add the main method to this second class by writing it in yourself. To run the program for part two, simply right click on the part two class file in the project panel on the left side of the Netbeans window, then select Run File from the pop up menu.

Since you will have two programs both of which will run until the user asks to stop, it might be easy to forget to stop a running program. This can easily lead to having multiple programs running at the same time which can possibly lead to some issues. When you are testing your programs, make sure that there are no other program instances running before starting an instance of either part one or part two.

Part 1 The Account Administrator Program

This program allows an account administrator to request one of four possible actions. The following is the menu which an administrator should see:

Select one of the following operations:

1. Add an account

2. Delete an account

3. Generate report

4. Exit the system

Requirements: Your program must contain a function which presents this menu to the administrator, gets input from the administrator, and validates the input. If the input is incorrect, display an error message. Repeat until valid input is received. This function returns the valid input. This function will need to share a Scanner with the main method that calls this function, so it will need a Scanner as a parameter. Before returning from this function, make sure to call the Scanners nextLine function to dispose of any unprocessed end of line characters.

The information kept for each account includes a 10 digit account number, a 4 digit pin number, a name, and the account balance. The following illustrates how the account data is required to appear in the account information text file for this project:

5297460001:7848:Fred Barnes:100.00

5297460002:2459:Joe Green:200.96

5297460003:3791:Shirlee Cox:312.00

Notice that the colon character : is used to separate the four pieces of account information kept for each account. Also notice that each line in the file contains the information for one account. Using Notepad or Wordpad to open the account information file must result in the account information being displayed as shown above. (The specifics of your accounts will be different, but the format must be the same.)

You must have a function that adds an account. The function must have a parameter which is the name of the account holder. The function generates an account number for the account. Account numbers are 10 digit numbers. Account numbers will need to be treated as long values rather than int values. The starting value for account numbers should be a value such as "5297460000". The new account number will be one more that the last account number added. A 4 digit pin number must be randomly generated with a minimum value of 1000. Initial balance on a new account is zero. A new account is added to the end of the file containing existing accounts. If there is a problem writing the file, output an appropriate error message.

You must have a function that deletes an account. This function takes the account number to be deleted as a parameter. The strategy for deleting from a file is to read each account from the existing account file, and write each account except the one to be deleted to a temporary file.

After closing both files, use a File object to delete the existing account file, and rename the temporary file to the existing account file name. Make sure to deal with the possibility that the account to be deleted is not in the existing account file. Output an appropriate error message in this case.

You must have a function to generate a report of all the existing accounts. This function should display account information for all accounts similar to the following example:

5297460001 7848 Fred Barnes 100.00

5297460002 2459 Joe Green 200.00

5297460003 3791 Shirlee Cox 300.00

The main function handles some user interaction, calls the other functions and runs until the user exits the system.

Part 2 The Account User Program

This program allows an account user to request one of four possible actions. The following is the menu which an account user should see:

Select one of the following operations:

1. Get account balance

2. Make a deposit

3. Make a withdrawal

4. Exit the system

Requirements: Your program must contain a function which presents this menu to the account user, gets input from the account user, and validates the input. If the input is incorrect, display an error message. Repeat until valid input is received. This function returns the valid input. This function will need to share a Scanner with the main method that calls this function, so it will need a Scanner as a parameter. Before returning from this function, make sure to call the Scanners nextLine function to dispose of any unprocessed end of line characters.

Your program must also contain at least the following functions:

getBalance: parameters are account number and pin

deposit: parameters are account number, pin, and amount

withdraw: parameters are account number, pin, and amount

All three of these functions require that the account number and pin be validated before anything else can happen to the account (hint: a separate function for validation might be a good idea!). Validation can fail if the account number is not found, or the pin for the account does not match. An appropriate error message should be displayed in either case.

The getBalance function simply prints the balance for accounts that have been validated.

The deposit and withdraw functions both have the possibility of changing an existing account balance for accounts that have been validated. (hint: a separate function for updating an account might be a good idea!). The withdraw function does not change the existing account if the amount being withdrawn exceeds the account balance. An appropriate error message is displayed in this case. When updating an account, use a strategy similar to that used to delete an account in part one. Read existing accounts and write them to a temporary file. When the account being updated is read, the updated account information is written to the temporary file.

String Operations

There are several String functions that are needed for this project.

split takes a string and creates an array of strings based on the field separator specified

startsWith checks to see if a string starts with the specified pattern

equals checks to see if two strings contain the same characters

Documentation

Make sure you document both parts of this project. A description of the program should be included in a Javadoc comment before the start of each class containing your program. Every function must include a Javadoc comment describing the purpose, parameters, and return value.

Submission

Create a zip file of the project and upload your zip file to the Pilot drop box before the project due date. Also, copy your source code into a text file (preferably Wordpad) and submit that separately to the drop box. Ask your TA for help if you have any questions.

NOTE: If the submitted project does not compile, it will receive zero points.

Rubric (50 pts)

Part One (23)

Adding an account works as described (5)

Deleting an account works as described (5)

Generating report of accounts works as described (5)

Menu function works as described (5)

Main works as described (3)

Part Two (23)

Getting account balance works as described (5)

Deposit into account works as described (5)

Withdraw from account works as described (5)

Menu function works as described (5)

Main works as described (3)

Proper coding style is followed. Comments provided as described. (4)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DNA Databases

Authors: Stefan Kiesbye

1st Edition

0737758910, 978-0737758917

More Books

Students also viewed these Databases questions

Question

The company has fair promotion/advancement policies.

Answered: 1 week ago