JAVA Project (1)
JAVA Project (1)
Project Report of
By
CERTIFICATE
Supervisor
----------------------------
Mrs. Sayani Chandra
Assistant Professor
Department of Computer Science and Engineering
GNIT, Kolkata.
----------------------------------
Head of the Department
Department of Computer Science and Engineering,
GNIT, Kolkata
INDEX
SL.
TOPIC PAGE NO.
NO.
1. OVERVIEW 1
2. FEATURES 1-2
6. CODE 5-8
8. CONCLUSION 9-11
ACKNOWLEDGEMENT
We should like to express our special thanks of gratitude to our professor
Mrs. Sayani Chandra who gave us the golden opportunity to do this
wonderful project Application of “Simple Banking Application’’. Those
who helped us in completing our project. We came to know about so
many new things. We are really thankful to them. Secondly, we would
also like to thank to all project group members for finalizing this project
within the limited time frame.
Rohan Pal
---------------------------
Bikram Ghosh
Date: _______________
Place:_______________ ---------------------------
Aniket Das
---------------------------
Adeeb Hussain
---------------------------
Smarta Das
---------------------------
Simple Banking Application
Overview
T
he Simple Banking Application is a console-based program
designed to simulate basic banking operations in a user-friendly
manner. This application serves as an educational example to
demonstrate core programming concepts, including object-oriented
programming, encapsulation, and method invocation in Java. It allows
users to interact with a virtual bank account by performing fundamental
operations such as:
1. Checking the current account balance.
2. Depositing a specified amount of money into the account.
3. Withdrawing a specified amount of money from the account.
4. Viewing details of the most recent transaction.
5. Exiting the application when operations are complete.
The program is implemented with two main classes: banking, which
contains the main method to initiate the program, and BankAccount,
which encapsulates the account-related functionalities. The application
starts by welcoming the user, displaying their name and account ID, and
presenting a menu of options for interaction. Users can perform
operations repeatedly until they choose to exit. This project is ideal for
demonstrating the practical application of Java programming skills in
real-world scenarios.
Features
1. Check Balance: View the current balance of the account.
2. Deposit Money: Add money to the account balance.
3. Withdraw Money: Deduct money from the account balance.
4. View Previous Transaction: Display the most recent transaction.
5. Exit: Close the application.
1. banking Class
Purpose: Serves as the entry point for the application.
Key Method:
o main(String[] args): Creates a BankAccount object and
invokes the showMenu() method.
2. BankAccount Class
Purpose: Contains methods and data to manage a bank account.
Attributes:
o int balance: Stores the current balance of the account (default:
50000).
o int previousTransaction: Stores the last transaction amount.
Positive for deposits, negative for withdrawals.
o String customerName: Stores the account holder's name.
o String customerId: Stores the account holder's ID.
Constructor:
o BankAccount(String cname, String cid): Initializes
customerName and customerId.
Methods:
1. void deposit(int amount):
Adds the specified amount to the balance.
Updates the previousTransaction.
2. void withdraw(int amount):
Deducts the specified amount from the balance.
Updates the previousTransaction.
3. void getPreviousTransaction():
Displays the most recent transaction:
"Deposited: [amount]" for a positive value.
"Withdraw: [amount]" for a negative value.
"No transaction occurred" if no transaction exists.
4. void showMenu():
Displays a menu with banking options.
Accepts user input for operations:
Option 1: Check Balance.
Option 2: Deposit Money.
Option 3: Withdraw Money.
Option 4: View Previous Transaction.
Option 5: Exit.
Executes corresponding actions using a switch statement.
How It Works
1. The application starts by creating an instance of BankAccount with
the user's name and ID.
2. The showMenu() method is invoked to display a menu of options.
3. The user can select an option by entering the corresponding number.
4. The program performs the selected operation and repeats the menu
until the user chooses to exit.
Key Points
1. Initial Balance:
o The account is initialized with a default balance of 50,000 units.
This ensures that the user has a starting amount to perform
operations like withdrawals and viewing their balance. It also
simplifies testing and demonstration of the application's
features.
2. Error Handling:
o The program gracefully manages invalid inputs by displaying
an error message, such as when a user enters an option outside
the valid range (1-5). This prevents unexpected crashes and
improves user experience by guiding users to provide correct
input.
3. User-Friendly Interface:
o The interactive menu-driven interface is straightforward and
allows users to select operations easily. Each action is clearly
explained, and prompts guide the user through each step of the
process. For example, users are prompted to enter an amount
when performing deposits or withdrawals.
4. Transaction Tracking:
o The previousTransaction attribute keeps track of the most
recent operation, whether it is a deposit or a withdrawal. This
allows users to review their last transaction, promoting
transparency and trust in the system.
5. Encapsulation and Modularity:
o The application employs encapsulation by using the
BankAccount class to manage account-specific data and
methods. This modular approach ensures that the main class
(banking) remains clean and focused on initiating the program,
while the BankAccount class handles the core logic.
6. Extensibility:
o The program is designed in a way that it can be easily extended.
For instance, adding features like interest calculation, multiple
account support, or saving account data to files can be done
without significantly altering the existing structure.
Code:
import java.util.Scanner;
class banking
{
class BankAccount
{
int balance=50000;
int previousTransaction;
String customerName;
String customerId;
void getPreviousTransaction()
{
if(previousTransaction > 0 )
{
System.out.println("Deposited : " + previousTransaction);
}
else if(previousTransaction < 0 )
{
System.out.println("withdraw : " + previousTransaction);
}
else
{
System.out.println("no transaction is occured...!");
}
}
void showMenu()
{
char option ='\0';
Scanner sc = new Scanner(System.in);
switch(option)
{
case '1' :
System.out.println("*************************************");
System.out.println("Your bank balance is : "+ balance);
System.out.println();
break;
case '2' :
System.out.println("*************************************");
System.out.println("Enter the amount to deposit : ");
int amount = sc.nextInt();
deposit(amount);
System.out.println("*************************************");
System.out.println("After deposit your bank balance is : "+ balance);
break;
case '3' :
System.out.println("*************************************");
System.out.println("Enter the amount to withdraw : ");
int amount2 = sc.nextInt();
withdraw(amount2);
System.out.println("*************************************");
System.out.println("After withdraw your bank balance is : "+ balance);
break;
case '4' :
System.out.println("*************************************");
getPreviousTransaction();
System.out.println();
break;
case '5' :
System.out.println("*************************************");
break;
default :
System.out.println("************Invalid option Please try
again************");
}
}while(option != '5');
}
}
Sample Input/Output
1. Check Balance
2. Deposit
3. Withdraw
4. Previous Transaction
5. Exit
Conclusion
T
his banking application demonstrates the use of classes, methods,
and object-oriented programming concepts in Java. By
structuring the program into distinct classes with clear
responsibilities, the code is both modular and easy to understand. The
interactive menu-driven interface enhances the user experience and
allows for repetitive operations until the user decides to exit.
Furthermore, the application highlights practical uses of variables,
control structures, and method invocations, making it an excellent
example for educational purposes.
The program can also be expanded further by incorporating advanced
features such as:
1. Adding multiple accounts with unique IDs.
2. Implementing authentication using passwords or PINs.
3. Including additional transaction types, such as transferring money
between accounts.
4. Integrating file handling to save and retrieve account data for
persistence.
Overall, this application serves as a solid foundation for understanding
basic banking systems and exploring more advanced programming
techniques.