Flow chart diagram and user manual

profilekhloud
banksimulation_report.docx

Kingdom of Saudi Arabia

المملكة العربية السعودية

Royal Commission at Yanbu

الهيئة الملكية ينبع

Yanbu University College

الكلية الجامعية-ينبع

Department of CSE

Yanbu Al-Sinaiyah

ينبع الصناعية

DATA STRUCTURES (CS 204)

ACADEMIC YEAR 2014-2015(SEM142)

PROJECT REPORT

“BANK SIMULATION”

BY

RAHMA ALHJJAJI 12120078

ASMA HAMID

INSTRUCTOR: MS. SALMA SADIQAH

DATE OF SUBMISSION 11 MAY, 2015

Table of Contents PROJECT REPORT 1 ACKNOWLEDGEMENT 2 1. EXECUTIVE SUMMARY 3 3. INTRODUCTION 4 3.1System Overview: 4 3.2 Team Members Responsibility: 4 4. SYSTEM ANALYSIS AND DESIGN 5 4.1System Objective: 5 4.2System Scope: 5 4.3System Design 5 5. Application Development 7 5.1System Implementation: 7 5.2 The program code: 8 6. CONCLUSION 16 7. APPENDICES 16 7.1 Appendix A:user manual: 16 7.2 Appendix B:flow chart diagram: 16 8. REFRENCES 17

ACKNOWLEDGEMENT

we would like to express our special thanks of gratitude to our teacher Salma Sadiqha as well as Rahma’s brother Turki who gave us the golden opportunity to do this wonderful project on the topic “Bank Simulation” which also helped us in doing a lot of research and we came to know about so many new things. they helped us a lot in finalizing this project within the limited time frame. we are really thankful to them.

1. EXECUTIVE SUMMARY

Banks have traditionally been in the forefront of harnessing technology to improve their products, services and efficiency. They have, over a long time, been using electronic and telecommunication networks for delivering a wide range of value added products and services. The delivery channels include direct dial – up connections, private networks, public networks etc and the devices include telephone, Personal Computers including the Automated Teller Machines, etc. With the popularity of PCs, easy access to Internet and World Wide Web (WWW), Internet is increasingly used by banks as a channel for receiving instructions and delivering their products and services to their customers. This form of banking is generally referred to as Bank simulation (Internet Banking), although the range of products and services offered by different banks vary widely both in their content and sophistication.

3. INTRODUCTION

3.1System Overview:

The proposed system is used to maintain a account record of all the customers of a Bank by storing entries for customer (i.e. account details),investments and showing their account summary. It also allows the customer to view their account without going to the bank and transaction can be done online.The customer need to login to his account by the provided username or id through the bank.

3.2 Team Members Responsibility:

1-Rahma Alhajjaji: searching, coding and report.

2-Asma Hamid: searching, coding and report.

4. SYSTEM ANALYSIS AND DESIGN

4.1System Objective:

These days, bank simulation (online banking) offers a genuinely cost-effective and timesaving method of conducting business. Security issues shouldn't stop the organizations around the world from adopting the technology.

4.2System Scope:

The system may be updated to its simple structure. This can further be used for maintenance of the account details for the customers and make the transaction easy for the customers, such as:

· paying bills

· paying wages

· transferring money between accounts

4.3System Design

The project has the following parts:

1. Give the customer three choices make account, login into account and close account.

2. After creating the customer’s account he/she has to login and set the initial balance

3. After the login the customer can do the transaction such as, deposit, withdraw ,fund transfe, check account statement and log out.

4. When the customer log out he/she will be able to see the first three choices again.

5. Application Development

5.1System Implementation:

The program Implemented by using linked list and its code consists of five classes:

1) LinkedList class:

It’s a Generic class made to store customers accounts.

-What’s a Generic class?

A generic class declaration looks like a non-generic class declaration, except that the class name is followed by a type parameter section.

-Why did we make it as Generic class?

 Generic classes enable programmers to specify, with a single method declaration, a set of related methods or, with a single class declaration, a set of related types, respectively.

Generics also provide compile-time type safety that allows programmers to catch invalid types at compile time.

2) Keyboard class:

This class created to take input from the customers. Try-catch used to ask for input from user (customer), and if we want the user to enter an integer there are chances that the user will input a character without the try-catch, the program will crash ,so the try-catch will try to convert the input to a number..if it fails, then it won’t crash the program but rather re-prompts the user to enter an input again.

3) Account class:

This class created to hold operations (behaviours) methods which they are deposit, withdraw ,transfer to another account, create an account and bank statement.

4) Transaction class:

This class created to get transaction operations amount and it could be deposit or withdraw.

5) Banking Application class:

The APP class which has the main method and here we can call all other classes by creating an object of each class and taking inputs from customer by using class scanner.

5.2 The program code:

//1-Linked List

// We're creating a linked list that can store of almost anything

public class LinkedList<T> {

private Node head;

// Create an empty linked list

public LinkedList() {

head = null;

}

// Insert a new element

public void add(T element) {

Node node = new Node(element);

node.next = head;

head = node;

}

// Count how many elements are there

public int size() {

int count = 0;

Node current = head;

while (current != null) {

count++;

current = current.next;

}

return count;

}

// Get a value of the node at the specified index

public T get(int i) {

Node current = head;

for (; i > 0; i--) {

current = current.next;

}

return current.element;

}

// Remove the element at the specified index

public void remove(T element) {

Node previous = null;

Node current = head;

while (current != null) {

if (current.element == element) {

if (previous == null) {

head = head.next;

} else {

previous.next = current.next;

}

break;

}

previous = current;

current = current.next;

}

}

private class Node {

public T element;

public Node next;

// Create a node

public Node(T element) {

this.element = element;

next = null;

}

}

}

////////////////////////////////////////////////////////////////

//2)Keyboard

import java.util.Scanner;

public class Keyboard {

private static Scanner keyboard = new Scanner(System. in );

// Forces the user to enter a double

public static double readDouble(String prompt) {

while (true) {

try {

System. out .print(prompt);

return Double.parseDouble(keyboard.nextLine());

} catch (Exception e) {

System. out .println("Error: Please enter a decimal number.");

}

}

}

// Forces the user to enter a integer

public static int readInt(String prompt) {

while (true) {

try {

System. out .print(prompt);

return Integer.parseInt(keyboard.nextLine());

} catch (Exception e) {

System. out .println("Error: Please enter a number.");

}

}

}

// Forces the user to enter a value

public static String readString(String prompt) {

while (true) {

System. out .print(prompt);

String value = keyboard.nextLine().trim();

if (!value.isEmpty()) {

return value;

}

System. out .println("Error: Please enter a value.");

}

}

}

///////////////////////////////////////////////////////

//3)Transaction

public class Transaction {

private String type;

private double amount;

private double resultingAmount;

// Create a transaction, which could either be a deposit or a withdraw

public Transaction(String type, double amount, double resultingAmount) {

this.type = type;

this.amount = amount;

this.resultingAmount = resultingAmount;

}

// Get the resulting amount of the transaction

public double getResultingAmount() {

return resultingAmount;

}

// Get type of transaction (deposit/withdrawal)

public String getType() {

return type;

}

// Get transaction amount

public double getAmount() {

return amount;

}

}

////////////////////////////////////////////

//4)Account

public class Account {

private String id;

private double balance;

private LinkedList<Transaction> transactions;

// Create a new account

public Account(String id, double balance) {

this.id = id;

this.balance = balance;

transactions = new LinkedList<Transaction>();

}

// Attempt to make a withdrawal transaction

public boolean withdraw(double amount) {

if (amount >= 0 && balance >= amount) {

double resultingAmount = balance - amount;

transactions.add(new Transaction("WITHDRAW", amount, resultingAmount));

balance = resultingAmount;

return true;

}

return false;

}

// Attempt to make a deposit

public boolean deposit(double amount) {

if(amount >= 0) {

double resultingAmount = balance + amount;

transactions.add(new Transaction("DEPOSIT", amount, resultingAmount));

balance = resultingAmount;

return true;

}

return false;

}

// Get account ID

public String getID() {

return id;

}

// Get account balance

public double getBalance() {

return balance;

}

// Return a statement of account of the account

@Override

public String toString() {

String string = "";

string += "Account ID: " + getID() + "\n";

string += "Balance : $" + String.format("%.2f", getBalance()) + "\n";

string += String.format("%15s", "Transaction");

string += String.format("%20s", "Amount");

string += String.format("%20s", "Balance");

string += "\n";

for(int i = 0; i < transactions.size(); i++) {

Transaction transaction = transactions.get(i);

string += String.format("%15s", transaction.getType());

string += String.format("%20s", "$" + String.format("%.2f", transaction.getAmount()));

string += String.format("%20s", "$" + String.format("%.2f", transaction.getResultingAmount()));

string += "\n";

}

return string;

}

}

////////////////////////////////

//5)BankingApplication

public class BankingApplication {

private static LinkedList<Account> accounts = new LinkedList<Account>();

// Find an account given ID from the list

private static Account findAccount(String id) {

for (int i = 0; i < accounts.size(); i++) {

Account account = accounts.get(i);

if (account.getID().equalsIgnoreCase(id)) {

return account;

}

}

return null;

}

// Create a new account

private static void openAccount() {

String id = Keyboard.readString("Enter a unique account ID: ");

if (findAccount(id) != null) {

System. out .println("Error: Account ID is already taken.");

return;

}

double balance = Keyboard.readDouble("Enter initial balance: ");

while (balance <= 0) {

System. out .println("Error: Balance should be > 0.");

balance = Keyboard.readDouble("Enter initial balance: ");

}

accounts.add(new Account(id, balance));

System. out .println("Success: Account created.");

}

// Close an account

private static void closeAccount() {

String id = Keyboard.readString("Enter account ID: ");

Account account = findAccount(id);

if (account == null) {

System. out .println("Error: Account does not exist.");

return;

}

accounts.remove(account);

System. out .println("Success: Account closed.");

}

// Login an account for a transaction

private static void loginAccount() {

String id = Keyboard.readString("Enter account ID: ");

Account account = findAccount(id);

if (account == null) {

System. out .println("Error: Account does not exist.");

return;

}

while (true) {

// Display Menu

System. out .println("ACCOUNT MENU");

System. out .println("1 - Deposit");

System. out .println("2 - Withdraw");

System. out .println("3 - Statement of Account.");

System. out .println("4 - Fund Transfer");

System. out .println("0 - Logout");

// Check what user wants to do

switch (Keyboard.readInt("Option: ")) {

case 1: {

double amount = Keyboard.readDouble("Enter amount: ");

if (amount <= 0) {

System. out .println("Error: Amount should be > 0.");

return;

}

account.deposit(amount);

System. out .println("Success: Deposit transaction accepted.");

}

break;

case 2: {

double amount = Keyboard.readDouble("Enter amount: ");

if (amount <= 0) {

System. out .println("Error: Amount should be > 0.");

return;

}

if (account.withdraw(amount)) {

System. out .println("Success: Withdraw transaction accepted.");

} else {

System. out .println("Error: Insufficient funds.");

}

}

break;

case 3:

System. out .println(account);

break;

case 4: {

Account toAccount = findAccount(Keyboard.readString("Enter beneficial account ID: "));

if (toAccount == null) {

System. out .println("Error: Account does not exist.");

} else if (toAccount == account) {

System. out .println("Error: Cannot transfer to your own account.");

} else {

double amount = Keyboard.readDouble("Enter amount: ");

if (amount <= 0) {

System. out .println("Error: Amount should be > 0.");

} else if (account.withdraw(amount)) {

toAccount.deposit(amount);

System. out .println("Success: Transfer fund complete.");

} else {

System. out .println("Error: Insufficient funds.");

}

}

}

break;

case 0:

return;

}

}

}

// Entry point of the program

public static void main(String[] args) {

while (true) {

// Display menu

System. out .println("MENU");

System. out .println("1 - Open an account");

System. out .println("2 - Login an account");

System. out .println("3 - Close an account");

System. out .println("0 - Exit");

// Check what user wants to do

switch (Keyboard.readInt("Option: ")) {

case 1:

// Create a new account

openAccount();

break;

case 2:

// Login for transactions

loginAccount();

break;

case 3:

// Delete account

closeAccount();

break;

case 0:

// Exit

return;

}

}

}

}

////////////////////////////////////////////////////////

6. CONCLUSION

The Bank Simulation has been developed and the system was tested with sample data.The system results in regular timely preparations of required outputs.The system provides a user friendly environment for the customers to do banking without going to the bank itself, allows the facility like opening the new account and transferring the money.

7. APPENDICES

7.1 Appendix A:user manual:

7.2 Appendix B:flow chart diagram:

8. REFRENCES

-https://www.cs.drexel.edu/~mcs172/Sp01/assignments/HW6-BankLine/index.html

-http://www.javatpoint.com/understanding-toString%28%29-method

-http://www.javapractices.com/topic/TopicAction.do?Id=55

-http://stackoverflow.com/questions/3615721/how-to-use-the-tostring-method-in-java

-https://docs.oracle.com/javase/tutorial/essential/exceptions/try.html

-http://www.javatpoint.com/try-catch-block

- http://www.dreamincode.net/forums/topic/273587-bank-simulation-using-queues/

3