pg.
1
INTRODUCTION
Java is an object-oriented programming language developed
by James Gosling in "sun microsystems" and it was released in 1995.
Java is a set of features of c and c++. It has obtained its format
from c and features from c++.
Java code that runs on one platform does not need to be
recompiled to run on another platform it's called write once, run
anywhere (WORA).
Some Important features of java are given below:
1. Simple
2. Object-Oriented
3. Portable
4. Platform independent
5. Secured
6. Robust
7. Architecture neutral
8. Interpreted
9. High Performance
10. Multithreaded
11. Distributed
12. Dynamic
About the micro-project:
pg. 2
In this micro project, we create a small banking system in
which some of the banking related options like withdrawal, deposit,
etc.
This java program has following main menus:
1) Display All
2) Search By Account
3) Deposit
4) Withdrawal
5) Exit
Initially, we will add some (N) customers to the bank and then
we can display all account details using menu 1).
menu 2) is used to search the bank account.
menu 3) is used to deposit money in particular account.
menu 4) is used to manager withdrawal.
menu 5) is used to exit from the program.
Program code
import java.util.Scanner;
class Bank
{
private String accno;
private String name;
private long balance;
Scanner KB=new Scanner(System.in);
//method to open an account
void openAccount()
{
System.out.print("Enter Account No: ");
accno=KB.next();
System.out.print("Enter Name: ");
name=KB.next();
System.out.print("Enter Balance: ");
balance=KB.nextLong();
}
pg. 3
//method to display account details
void showAccount()
{
System.out.println(accno+","+name+","+balance);
}
//method to deposit money
void deposit()
{
long amt;
System.out.println("Enter Amount U Want to Deposit: ");
amt=KB.nextLong();
balance=balance+amt;
}
//method to withdraw money
void withdrawal()
{
long amt;
System.out.println("Enter Amount U Want to withdraw:”);
amt=KB.nextLong();
if(balance>=amt)
{
balance=balance-amt;
}
else
{
System.out.println("Less Balance..Transaction
Failed..");
}
}
//method to search an account number
boolean search(String acn)
{
if(accno.equals(acn))
{
showAccount();
return(true);
}
return(false);
}
}
class ExBank
{
public static void main(String arg[])
pg. 4
{
Scanner KB=new Scanner(System.in);
//create initial accounts
System.out.print("How Many Customer U Want to Input :
");
int n=KB.nextInt();
Bank C[]=new Bank[n];
for(int i=0;i<C.length;i++)
{
C[i]=new Bank();
C[i].openAccount();
}
//run loop until menu 5 is not pressed
int ch;
do
{
System.out.println("Main Menu\n
1.Display All\n
2.Search By Account\n
3.Deposit\n
4.Withdrawal\n
5.Exit");
System.out.println("Ur Choice :");
ch=KB.nextInt();
switch(ch)
{
case 1:
for(int i=0;i<C.length;i++)
{
C[i].showAccount();
}
break;
case 2:
System.out.print("Enter Account No
U Want to Search.... ");
String acn=KB.next();
boolean found=false;
for(int i=0;i<C.length;i++)
{
found=C[i].search(acn);
if(found)
pg. 5
{
break;
}
}
if(!found)
{
System.out.println("Search Failed..Not
Exist..");
}
break;
case 3:
System.out.print("Enter Account No : ");
acn=KB.next();
found=false;
for(int i=0;i<C.length;i++)
{
found=C[i].search(acn);
if(found)
{
C[i].deposit();
break;
}
}
if(!found)
{
System.out.println("Search
Failed..Account.
Not
Exist..");
}
break;
case 4:
System.out.print("Enter Account No : ");
acn=KB.next();
found=false;
for(int i=0;i<C.length;i++)
{
found=C[i].search(acn);
if(found)
{
C[i].withdrawal();
break;
pg. 6
}
}
if(!found)
{
System.out.println("Search. Failed
account
not
Exist.. ");
}
break;
case 5:
System.out.println("Good Bye..");
break;
}
}
while(ch!=5);
}
}
pg. 7
pg. 8
pg. 9
pg. 10