0% found this document useful (0 votes)
25 views4 pages

Java Bank Account Management System

Uploaded by

dyammanu
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views4 pages

Java Bank Account Management System

Uploaded by

dyammanu
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

package JavaProject;

import [Link];

class BankAccount{

String name;
String userName;
String password;
String accountNo;
float balance = 10000f;
int transactions = 0;
String transactionHistory = "";

public void register() {


Scanner sc = new Scanner([Link]);
[Link]("\nEnter your Name: ");
[Link] = [Link]();
[Link]("\nEnter your Username: ");
[Link] = [Link]();
[Link]("\nEnter your Password: ");
[Link] = [Link]();
[Link]("\nEnter your Account Number: ");
[Link] = [Link]();
[Link]("\nRegistration Successful. Please Log in to your
Bank Account");
}
public boolean login() {
boolean isLogin = false;
Scanner sc=new Scanner([Link]);
while( !isLogin) {
[Link]("\nEnter your username: ");
String Username = [Link]();
if ([Link](userName)) {
while(!isLogin) {
[Link]("\nEnter your password: ");
String Password = [Link]();
if([Link](password)) {
[Link]("\nLogin Successful");
isLogin = true;
}
else {
[Link]("\nIncorrect Password");
}
}
}else {
[Link]("\nUsername not found");
}
}
return isLogin;
}

public void withdraw() {


[Link]("\nEnter Amount to Withdraw: ");
Scanner sc=new Scanner([Link]);
float amount = [Link]();
try {
if(balance >= amount) {
transactions++;
balance -= amount;
[Link]("\nWithdral Successful.");
String str = amount + "Rs Withdrawn\n";
transactionHistory = [Link](str);
}else {
[Link]("\nInsufficient Balance.");
}
}catch(Exception e) {

public void deposit() {


[Link]("\nEnter Amount to Deposit: ");
Scanner sc=new Scanner([Link]);
float amount = [Link]();
try {
if(amount <= 10000f) {
transactions++;
balance += amount;
[Link]("\nDeposit Successful.");
String str = amount + "Rs deposited\n";
transactionHistory = [Link](str);
}else {
[Link]("\nSorry. The limit is 10000.");
}
}catch(Exception e) {

public void transfer() {


Scanner sc=new Scanner([Link]);
[Link]("\nEnter Receipent's Name: ");
String receipent = [Link]();
[Link]("\nEnter Amount to transfer: ");
float amount = [Link]();
try {
if(balance>= amount) {
if(amount <= 50000f) {
transactions++;
balance -= amount;
[Link]("\nSuccesfully Transferred to "+
receipent);
String str = amount + "Rs transferred to " + receipent+"\
n";
transactionHistory = [Link](str);
}else {
[Link]("\nSorry. The limit is 50000.");
}
}else{
[Link]("\nInsufficient Balance.");
}}catch(Exception e) {
}

}
public void checkBalance() {
[Link]("\n"+balance+"Rs");
}

public void transHistory() {


if(transactions ==0) {
[Link]("No TRansactions happened");
}else {
[Link]("\n"+transactionHistory);
}
}
}

public class ATMInterface {

public static int takenIntegerInput(int limit) {


int input = 0;
boolean flag = false;

while(!flag) {
try {
Scanner sc = new Scanner([Link]);
input = [Link]();
flag = true;

if(flag && input>limit || input<1) {


[Link]("Choose the number between 1 to
"+limit);
flag=false;
}
}catch(Exception e) {
[Link]("Enter only integer value.");
flag=false;
}
}
return input;
}

public static void main(String[] args) {


[Link]("\n********************WELCOME TO GOVARDHAN ATM
INTERFACE*******************");
[Link]("\[Link] \[Link]");
[Link]("Choose one option: ");
int choose = takenIntegerInput(2);

if(choose == 1) {
BankAccount b= new BankAccount();
[Link]();
while(true) {
[Link]("\[Link] \[Link]");
[Link]("Enter your choice: ");
int ch = takenIntegerInput(2);
if(ch==1) {
if([Link]()) {
[Link]("\
n********************WELCOME BACK"+[Link] +"*******************");
boolean isFinished = false;
while(!isFinished) {
[Link]("\[Link] \
[Link] \[Link] \[Link] balance \[Link] History \[Link]");
[Link]("Enter your choice:
");
int c = takenIntegerInput(6);
switch(c) {
case 1:
[Link]();
break;
case 2:
[Link]();
break;
case 3:
[Link]();
break;
case 4:
[Link]();
break;
case 5:
[Link]();
break;
case 6:
isFinished = true;
break;
}
}
}
}else {
[Link](0);
}

}
}else {
[Link](0);
}
}

Common questions

Powered by AI

The transactional operations in the BankAccount class are managed through methods for withdrawal, deposit, and transfer. Withdrawals check if the balance is sufficient before subtracting the requested amount from the balance; deposits are limited to a maximum of 10,000; transfers have a maximum limit of 50,000; and all transactions update the balance and transaction history upon successful completion. These operations use exception handling to capture and manage input errors. However, there is no consideration for invalid input types in withdrawal or deposit amounts .

The ATMInterface class facilitates user interaction by providing a console-based menu system that allows users to register, login, and perform transactions on their bank account, such as withdrawing, depositing, transferring funds, checking balance, and viewing transaction history. Interaction is enabled using console prompts and a method that ensures only integer input within a specified range is accepted. However, the interface lacks flexibility because it operates entirely through command-line prompts without any graphical user interface, which could be considered a significant limitation .

The transactional methods in the BankAccount class use try-catch blocks to manage exceptions, such as input errors during transactions. This basic error handling doesn't provide specific feedback for different types of user mistakes, such as non-numeric input or exceeding transaction limits, which reduces the robustness of the application. Improvements could include adding more specific exception types and messages, comprehensive input validation, and better user feedback on input constraints .

Storing sensitive user information like passwords, account numbers, and usernames directly in string fields poses significant security risks, as these could be exposed in the event of code leaks or during debugging. These can be mitigated by encrypting sensitive information before storage and utilizing secure password storage practices, such as hashing. Additionally, adopting secure coding practices and following best practices for access control within the application can prevent unauthorized access .

Advantages of using the console for user interaction include simplicity in implementation and cross-platform compatibility, making the application lightweight and easy to run without additional libraries . Disadvantages include a lack of intuitive user interface design, limited interaction capabilities compared to graphical interfaces, and potential usability issues for non-technical users. As consoles do not allow for mouse inputs or graphical elements, the user experience can be seen as less engaging and less efficient .

The BankAccount class uses a method called 'register' for user registration. The steps involved are: the system prompts the user to enter their Name, Username, Password, and Account Number using the Scanner class for input. These details are then stored in the respective fields of the BankAccount object. A success message prompts the user to log in to their account after registration .

The program ensures user authentication by matching the provided username and password against stored values in the BankAccount class fields . While sufficient for basic applications, this approach is insufficient for real-world applications because it does not secure password storage, lacks multi-factor authentication, and does not protect against brute force attacks. Enhancements could include password hashing, implementing account lockout mechanisms, and adding additional security measures like contextual authentication .

The ATMInterface class ensures valid input by using a method called 'takenIntegerInput' which continuously prompts the user to enter an integer value until a valid integer within the specified range is received. It uses exception handling to capture any invalid input and displays a message guiding the user to provide valid input. This solution effectively prevents the program from crashing due to input errors, but it adds extra loops and delays that could impact user experience if not managed properly .

The BankAccount class implements a login process by requesting the user's username and password through the console. The login method contains a loop that prompts the user to input their credentials. It first checks if the entered username matches the stored username. If it matches, it then prompts for the password. If both the username and password match, a success message is displayed, and the login process is completed. Otherwise, it continues to prompt the user until the correct credentials are provided .

The BankAccount class manages transaction history by appending each transaction to a string variable 'transactionHistory' whenever a transaction is performed . Potential improvements include using a more structured approach to logging transactions, such as storing entries in a list or database with timestamps, transaction types, and additional metadata (e.g., transfer recipients). This would facilitate easier tracking, querying, and filtering of historical transactions .

You might also like