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

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.
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...
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...
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....
Develop a Java application which implements an application for a store chain that has three types...
Develop a Java application which implements an application for a store chain that has three types of stores which are Book, Music, and Movie stores. Your application should have an Item abstract class which should be extended by the Book and Multimedia classes. Item class has abstract priceAfterTax method, you need to implement this method in derived classes. Multimedia class is a superclass for Music and Movie classes. Your project should also include the IPromotion interface, which should be implemented...
using Java Your mission in this exercise is to implement a very simple Java painting application....
using Java Your mission in this exercise is to implement a very simple Java painting application. Rapid Prototyping The JFrame is an example that can support the following functions: 1. Draw curves, specified by a mouse drag. 2. Draw filled rectangles or ovals, specified by a mouse drag (don't worry about dynamically drawing the shape during the drag - just draw the final shape indicated). 3. Shape selection (line, rectangle or oval) selected by a combo box OR menu. 4....
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
How can be the function of the vestibular system evaluated? What is clinical application of caloric...
How can be the function of the vestibular system evaluated? What is clinical application of caloric testing? Explain in your own words and give examples
Create a PowersTable application that displays a table of of powers. ( Java Programing )
Create a PowersTable application that displays a table of of powers. ( Java Programing )
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT