Question

In: Computer Science

how to creat a bank system application for Java?

how to creat a bank system application for Java?

Solutions

Expert Solution

A banking system should contain a few essential features which are a must in any banking system

1. Account adding capacity and also able to search the account already present

2. able to deposit and withdraw money

3. able to check the balance in the account and enable the system to maintain a minimum balance.

an example of the bank system is given below

import java.util.Scanner;

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

   Scanner K =new Scanner(System.in);
  
   //method to open an account
   void openAccount()
   {
       System.out.print("Enter Account No: ");
       accno=K.next();
       System.out.print("Enter  Name: ");
user_name=K.next();
       System.out.print("Enter Balance: ");
       balance=K.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 the Amount you  Want to Deposit : ");
       amt=K.nextLong();
       balance=balance+amt;
   }

   //method to withdraw money
   void withdrawal()
   {
       long amt;
       System.out.println("Enter the Amount you Want to withdraw : ");
       amt=K.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 you  Want to Input : ");
       int n=K.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=K.nextInt();
           switch(ch)
           {
               case 1:
                   for(int i=0;i<C.length;i++)
                   {
                       C[i].showAccount();
                   }
                   break;

               case 2:
                   System.out.print("Enter Account to be Search ");
                   String acn=K.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=K.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=K.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("transaction over ");
                   break;
           }
       }
       while(ch!=5);
   }
}


Related Solutions

It is required to develop an application in Java to perform some operations of a bank....
It is required to develop an application in Java to perform some operations of a bank. The application will have the following classes: Class called Person having following data fields (private): firstName (String), lastName(String), gender(char), cpr(long), mobile(String) and following methods: Constructor having 5 parameters to initialize all data fields, Set and get methods for all data fields, toString method to return String equivalent of all data fields, Abstract class called Account having following data fields(protected): accountHolder(Person), ccountNum(long), balance(double)and following methods:...
Creat a program that is part of a control system for a house. Create two Boolean...
Creat a program that is part of a control system for a house. Create two Boolean variables: doorUnLocked and lightOn. Set both to false. Create an int variable: currentTemp. Set the currentTemp value to 70 Create two more Boolean variables: heatOn and coolingOn. Set both of these values to false. Ask the user if they want to unlock the door, turn on the light and what value the temperature should be. If they want to unlock the door, set doorUnlocked...
write half of page of how creat relationships with others
write half of page of how creat relationships with others
How to write a java application that reads an integer, then determines and display whether it's...
How to write a java application that reads an integer, then determines and display whether it's odd or even. Use the remainder operator.
In Java Develop, test, and execute a graphics application for simulations using Java. Create a Java...
In Java Develop, test, and execute a graphics application for simulations using Java. Create a Java application. Given a set of events, choose the resulting programming actions. Understand the principles behind Java. Understand the basic principles of object-oriented programming including classes and inheritance. Deliverables .java files as requested below. Requirements Create all the panels. Create the navigation between them. Start navigation via the intro screen. The user makes a confirmation to enter the main panel. The user goes to the...
Java 2D Drawing Application. The application will contain the following elements: a) an Undo button to...
Java 2D Drawing Application. The application will contain the following elements: a) an Undo button to undo the last shape drawn. b) a Clear button to clear all shapes from the drawing. c) a combo box for selecting the shape to draw, a line, oval, or rectangle. d) a checkbox which specifies if the shape should be filled or unfilled. e) a checkbox to specify whether to paint using a gradient. f) two JButtons that each show a JColorChooser dialog...
how to creat Create a text file that contains a list of integer numbers separated by...
how to creat Create a text file that contains a list of integer numbers separated by comma (numbers.txt). E.g. 3, 7, 5, 1, 11, 8,2, 6 2- how to Write a python program (minMax.py) to read the file numbers.txt and find the largest and smallest numbers in the file. (without using use min(), max()). calculate the average and output the results. 3-Use python file i/o, write a python program (fileCopy.py) that makes a copy of minMax.py (Read contents of minMax.cp...
please, solve this problem.: implementing with java language create a bank account management system according to...
please, solve this problem.: implementing with java language create a bank account management system according to the following specifications: BankAccount Abstract Class contains the following constructors and methods: BankAccount(name, balance): a constructor that creates a new account with a name and starting balance. getBalance(): a method that returns the balance of a specific account. abstract deposit(amount): abstract method to be implemented in both Checking and SavingAccount classes. abstract withdraw(amount): abstract method to be implemented in both Checking and SavingAccount classes....
Create a java Swing GUI application that presents the user with a “fortune”. Create a java...
Create a java Swing GUI application that presents the user with a “fortune”. Create a java Swing GUI application in a new Netbeans project called FortuneTeller. Your project will have a FortuneTellerFrame.java class (which inherits from JFrame) and a java main class: FortuneTellerViewer.java. Your application should have and use the following components: Top panel: A JLabel with text “Fortune Teller” (or something similar!) and an ImageIcon. Find an appropriate non-commercial Fortune Teller image for your ImageIcon. (The JLabel has a...
Assess the impacts of the application of a CRM system on retailing and store management. How...
Assess the impacts of the application of a CRM system on retailing and store management. How can this system support and improve the performance of both management disciplines? Propose different applications within this field of the marketing write in details
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT