import [Link].
Scanner;
class BankDetails {
private String accno;
private String name;
private String acc_type;
private long balance;
Scanner sc = new Scanner([Link]);
//method to open new account
public void openAccount() {
[Link]("Enter Account No: ");
accno = [Link]();
[Link]("Enter Account type: ");
acc_type = [Link]();
[Link]("Enter Name: ");
name = [Link]();
[Link]("Enter Balance: ");
balance = [Link]();
}
//method to display account details
public void showAccount() {
[Link]("Name of account holder: " + name);
[Link]("Account no.: " + accno);
[Link]("Account type: " + acc_type);
[Link]("Balance: " + balance);
}
//method to deposit money
public void deposit() {
long amt;
[Link]("Enter the amount you want to deposit: ");
amt = [Link]();
balance = balance + amt;
}
//method to withdraw money
public void withdrawal() {
long amt;
[Link]("Enter the amount you want to withdraw: ");
amt = [Link]();
if (balance >= amt) {
balance = balance - amt;
[Link]("Balance after withdrawal: " + balance);
} else {
[Link]("Your balance is less than " + amt + "\tTransaction
failed...!!" );
}
}
//method to search an account number
public boolean search(String ac_no) {
if ([Link](ac_no)) {
showAccount();
return (true);
}
return (false);
}
}
public class BankingApp {
public static void main(String arg[]) {
Scanner sc = new Scanner([Link]);
//create initial accounts
[Link]("How many number of customers do you want to input? ");
int n = [Link]();
BankDetails C[] = new BankDetails[n];
for (int i = 0; i < [Link]; i++) {
C[i] = new BankDetails();
C[i].openAccount();
}
// loop runs until number 5 is not pressed to exit
int ch;
do {
[Link]("\n ***Banking System Application***");
[Link]("1. Display all account details \n 2. Search by
Account number\n 3. Deposit the amount \n 4. Withdraw the amount \n [Link] ");
[Link]("Enter your choice: ");
ch = [Link]();
switch (ch) {
case 1:
for (int i = 0; i < [Link]; i++) {
C[i].showAccount();
}
break;
case 2:
[Link]("Enter account no. you want to search: ");
String ac_no = [Link]();
boolean found = false;
for (int i = 0; i < [Link]; i++) {
found = C[i].search(ac_no);
if (found) {
break;
}
}
if (!found) {
[Link]("Search failed! Account doesn't
exist..!!");
}
break;
case 3:
[Link]("Enter Account no. : ");
ac_no = [Link]();
found = false;
for (int i = 0; i < [Link]; i++) {
found = C[i].search(ac_no);
if (found) {
C[i].deposit();
break;
}
}
if (!found) {
[Link]("Search failed! Account doesn't
exist..!!");
}
break;
case 4:
[Link]("Enter Account No : ");
ac_no = [Link]();
found = false;
for (int i = 0; i < [Link]; i++) {
found = C[i].search(ac_no);
if (found) {
C[i].withdrawal();
break;
}
}
if (!found) {
[Link]("Search failed! Account doesn't
exist..!!");
}
break;
case 5:
[Link]("See you soon...");
break;
}
}
while (ch != 5);
}
}