Bank Account Management System in Java, Exercises of Java Programming

this is a program which is use in bank that how to create account and etc

Typology: Exercises

2017/2018

Uploaded on 10/25/2018

wahid-afridi
wahid-afridi 🇵🇰

4 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
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();
}
//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..");
}
}
pf3
pf4

Partial preview of the text

Download Bank Account Management System in Java and more Exercises Java Programming in PDF only on Docsity!

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

//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[]) { 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...: ");

System.out.println("Search Failed..Account Not Exist.."); } break;

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