0% found this document useful (0 votes)
6 views5 pages

Oop 9

Uploaded by

joshishridhar186
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)
6 views5 pages

Oop 9

Uploaded by

joshishridhar186
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
You are on page 1/ 5

import java.util.

Scanner;

class Bank
{
private String accno;
private String name;
private long balance;

Scanner KB = new Scanner(System.in);

void openAccount()
{
System.out.print("\nEnter Account No: ");
accno = KB.next();
System.out.print("Enter Name: ");
name = KB.next();
System.out.print("Enter Balance: ");
balance = KB.nextLong();
}

void showAccount()
{
System.out.println("\n"+accno + "/" + name + "/" + balance);
}

void deposit()
{
long amt;
System.out.println("Enter Amount U Want to Deposit : ");
amt = KB.nextLong();
balance = balance + amt;
}

void withdrawal()
{
long amt;
System.out.println("WTHDRAWAL LIMIT IS 15000 RS\nEnter Amount U Want to
withdraw : ");
amt = KB.nextLong();
if(amt<=15000)
{
if (balance >= amt)
{
balance = balance - amt;
}
else
{
System.out.println("Less Balance..Transaction Failed..");
}
}
else
{
System.out.println("Withdraw Limit Exceeded");
}
}
boolean search(String acn)
{
if (accno.equals(acn))
{
showAccount();
return (true);
}
return (false);
}
}

public class Hello{


public static void main(String arg[])
{
Scanner KB = new Scanner(System.in);

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();
}

int ch;
do {
System.out.println("\n***** Main Menu *****\n1. Display All\n2. Search
By Account\n3. Deposit\n4. Withdrawal\n5.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) {
break;
}
}
if (!found) {
System.out.println("Search Failed..Account 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;
}
}
if (!found) {
System.out.println("Search Failed..Account Not
Exist..");
}
break;

case 5:
System.out.println("Good Bye..");
break;
}
}
while (ch != 5);
}
}

OUTPUT:

How Many Customer U Want to Input : 1

Enter Account No: 31


Enter Name: Shridhar
Enter Balance: 10000

***** Main Menu *****


1. Display All
2. Search By Account
3. Deposit
4. Withdrawal
5.Exit
Ur Choice :
1

31,Shridhar,10000
***** Main Menu *****
1. Display All
2. Search By Account
3. Deposit
4. Withdrawal
5.Exit
Ur Choice :
2
Enter Account No U Want to Search...: 30
Search Failed..Account Not Exist..

***** Main Menu *****


1. Display All
2. Search By Account
3. Deposit
4. Withdrawal
5.Exit
Ur Choice :
2
Enter Account No U Want to Search...: 31

31,Shridhar,10000

***** Main Menu *****


1. Display All
2. Search By Account
3. Deposit
4. Withdrawal
5.Exit
Ur Choice :
3
Enter Account No : 31

31,Shridhar,10000
Enter Amount U Want to Deposit :
1000

***** Main Menu *****


1. Display All
2. Search By Account
3. Deposit
4. Withdrawal
5.Exit
Ur Choice :
1

31,Shridhar,11000

***** Main Menu *****


1. Display All
2. Search By Account
3. Deposit
4. Withdrawal
5.Exit
Ur Choice :
4
Enter Account No : 31
31,Shridhar,11000
WTHDRAWAL LIMIT IS 15000 RS
Enter Amount U Want to withdraw :
12000
Less Balance..Transaction Failed..

***** Main Menu *****


1. Display All
2. Search By Account
3. Deposit
4. Withdrawal
5.Exit
Ur Choice :
4
Enter Account No : 31

31,Shridhar,11000
WTHDRAWAL LIMIT IS 15000 RS
Enter Amount U Want to withdraw :
10000

***** Main Menu *****


1. Display All
2. Search By Account
3. Deposit
4. Withdrawal
5.Exit
Ur Choice :
1

31,Shridhar,1000

***** Main Menu *****


1. Display All
2. Search By Account
3. Deposit
4. Withdrawal
5.Exit
Ur Choice :
5
Good Bye..

You might also like