programa Java para el sistema de gestión bancaria

En este programa java, vamos a aprender a crear un pequeño proyecto como sistema bancario? En este programa, estamos utilizando algunas de las opciones bancarias relacionadas como depósito, retiro, etc. .

Este programa Java tiene menús siguientes class:

  1. visualizar todos
  2. Buscar Por Cuenta
  3. fuerte
  4. Retiro
  5. salida

Inicialmente , lo haremos añadir un poco de (N) a los clientes del banco y entonces podemos mostrar todos los detalles de la cuenta usando menú 1) , menú 2) se utiliza para buscar la cuenta bancaria, menú 3) se utiliza para depositar dinero en la cuenta, en particular , menú 4) se utiliza para la retirada gerente y menú 5) se utiliza para salir del programa.

Programa

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);
}
}
public 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 Menun1. Display Alln 2. Search By Accountn 3. Depositn 4. Withdrawaln 5.E xit ");
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);
}
}

salida

How Many Customer U Want to Input : 2
Enter Account No: 101
Enter Name: Chintu
Enter Balance: 25000
Enter Account No: 102
Enter Name: Alexander
Enter Balance: 30000
Main Menu
1.Display All
2.Search By Account
3.Deposit
4.Withdrawal
5.Exit
Ur Choice :
1
101,Chintu,25000
102,Alexander,30000
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...: 102
102,Alexander,30000
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...: 105
Search Failed..Account Not Exist..
Main Menu
1.Display All
2.Search By Account
3.Deposit
4.Withdrawal
5.Exit
Ur Choice :
3
Enter Account No : 102
102,Alexander,30000
Enter Amount U Want to Deposit :
25000
Main Menu
1.Display All
2.Search By Account
3.Deposit
4.Withdrawal
5.Exit
Ur Choice :
3
Enter Account No : 105
Search Failed..Account Not Exist..
Main Menu
1.Display All
2.Search By Account
3.Deposit
4.Withdrawal
5.Exit
Ur Choice :
4
Enter Account No : 102
102,Alexander,55000
Enter Amount U Want to withdraw :
15000
Main Menu
1.Display All
2.Search By Account
3.Deposit
4.Withdrawal
5.Exit
Ur Choice :
4
Enter Account No : 105
Search Failed..Account Not Exist..
Main Menu
1.Display All
2.Search By Account
3.Deposit
4.Withdrawal
5.Exit
Ur Choice :
5
Good Bye..


Deja un comentario

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *