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 theater booking system in java language using : 1.OOP objects -Classes 2.encapsulation 3.polymorphism 4.inheritance...
Creat a theater booking system in java language using : 1.OOP objects -Classes 2.encapsulation 3.polymorphism 4.inheritance 5.abstract class
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
Java- creat a method that takes two char parameters. Return a String containing all characters, in...
Java- creat a method that takes two char parameters. Return a String containing all characters, in order, from the first char parameter (inclusive) to the last (inclusive). For instance, input('a', 'e'), and return "abcde".
Implement a simple banking system in Java. Your application should demonstrate the following. Upon running the...
Implement a simple banking system in Java. Your application should demonstrate the following. Upon running the java code, first the application should welcome the user, then ask the user to give one of the options: 1) display the balance summary, 2) withdraw money, or 3) deposit money. Based on the options your code should perform the following operations such as 1) read the transaction details from a file and display them on the screen. 2) ask the user to enter...
Implement a simple banking system in Java. Your application should demonstrate the following. Upon running the...
Implement a simple banking system in Java. Your application should demonstrate the following. Upon running the java code, first the application should welcome the user, then ask the user to give one of the options: 1) display the balance summary, 2) withdraw money, or 3) deposit money. Based on the options your code should perform the following operations such as 1) read the transaction details from a file and display them on the screen. 2) ask the user to enter...
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 Write a Java console application that prompts the user to enter the radius of a...
JAVA Write a Java console application that prompts the user to enter the radius of a circle, then prints its radius, diameter, circumference, and area. The Console Output Enter the radius of the circle: 1.2 The radius is 1.2 The diameter is 2.4 The circumference is 7.5398223686155035 The area is 4.523893421169302 Programmer Notes Write and document your program per class coding conventions. Add an instance variable double radius. Generate its get/set methods. Manually type the methods getDiameter(), getCircumference(), and getArea()....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT