Skip to main content
Home
Live to Learn!

Main navigation

  • Home
  • Learn
    • FoxPro
    • MS-DOS
    • C PRG
    • Java
    • ASP
    • Ruby on Rails
    • ASP.NET
    • E-Books
    • Exam Preparation
    • Tools
  • Blog
  • Forums
  • Contact
User account menu
  • Log in

Breadcrumb

  1. Home
  2. Learn by Example - Java Sample Programs

Simple Bank Account Process

Book navigation

  • Armstrong Number
  • Palindrome Checking
  • Playing Audio Clip using Applet
  • Applet Form
  • Exception Handling
  • Multiple Inheritance and Packages
  • Shopping List
  • Simple Multithread program
  • JDBC Program Select, Insert, Update, Delete records
  • RMI - Example AddServer
  • Simple Bank Account Process
  • TCP Server and Client in Java
  • UDP Server and Client in Java
  • FTP Server and Client in Java
  • Chat Server and Client in Java
  • Echo Server and Client in Java
  • Address Resolution Protocol in Java
  • Ping server and Client in Java
  • Multicast Server and Client in Java
  • Transposition Cipher Method
  • Poly-alphabetic Cipher Method Encryption - Java
  • DES - Using Data Encryption Standard in Java
  • AES - Using Advanced Encryption Standard in Java
  • Bit Stuffing
By Karthik , 25 November, 2011

import java.io.*;
class account
{
        int no, type;
        String name;
        double bal;
        account(int x, String y, int z)
        {
                no = x;
                name = y;
                type = z;
                bal = 500;
        }
}
class sav_acc extends account
        {
                DataInputStream ds=new DataInputStream(System.in);
                sav_acc(int x, String y, int z)
                {
                        super(x,y,z);
                }
                void deposit1() throws IOException
                {
                        System.out.println("Enter deposit amount");
                        int dep = Integer.parseInt(ds.readLine());
                        double ci =  dep*(2.5/100);
                        bal = bal + ci + dep;
                        System.out.println("your balance is:" +bal);
                }
                void withdraw1() throws IOException
                {
                        System.out.println("Enter withdraw amount");
                        int wth = Integer.parseInt(ds.readLine());
                        bal = bal - wth;
                        if(bal<500)
                        {
                        System.out.println("Your balance is less than minimum amount");
                        bal = bal + wth;
			}
			else
			System.out.println("withdraw successfully");
                        System.out.println("Your balance is :"+bal);
                        }
                 }
class cur_acc extends sav_acc
 {
 DataInputStream ds = new DataInputStream(System.in);
 cur_acc(int x, String y, int z)
 {
        super(x,y,z);
 }
 void deposit2() throws IOException
 {
 if(type==1)
        deposit1();
 else
 {
 System.out.println("enter deposit amount");
 int dep = Integer.parseInt(ds.readLine());
 bal = bal+dep;
 System.out.println("Your balance is:"+bal);
 }
 }
 void withdraw2() throws IOException
    {
        if(type==1)
                withdraw1();
                else
                {
                System.out.println("Enter the check no:");
                int ch = Integer.parseInt(ds.readLine());
                System.out.println("Enter withdraw amount");
                int wth = Integer.parseInt(ds.readLine());
                bal = bal - wth;
                if (bal <500)
                {
                    System.out.println("Ur balance less than minimum");
                    bal = bal + wth;
                }
                else
                {
                System.out.println("Withdraw successfully");
                System.out.println("Ur balance is:" +bal + "and your withdraw c");
                }
                }
          }
          void display2() throws IOException
          {
                String fac;
                String t;
                if(type==1)
                {
                        fac = "False";
                        t = "Saving";
                }
                else
                {
                        fac="True";
                        t="current";
                }
         System.out.println("=========================================");
         System.out.println("Bank Account ");
         System.out.println("=========================================");
         System.out.println("Account Number    :" +no);
         System.out.println("Customer name    :" +name);
         System.out.println("Account Type    :" +t);
         System.out.println("Checque book    :" +fac);
         System.out.println("Account Number    :" +no);
         System.out.println("Current balance    :" +bal);
         System.out.println("=========================================");
         System.out.println("=========================================");
     }
 }
class BANK
 {
        public static void main(String ar[]) throws IOException
	{
        DataInputStream ds = new DataInputStream(System.in);
        System.out.println("    Bank Account");
        System.out.println("------------------------");
	System.out.println("Enter Account No. :");
        int n = Integer.parseInt(ds.readLine());
        System.out.println("Enter Customer Name :");
        String name = ds.readLine();
        System.out.println("1-> Saving Account");
        System.out.println("2-> Current Account");
        System.out.println("Select Account type");
        int t = Integer.parseInt(ds.readLine());
        cur_acc ob = new cur_acc(n, name, t);
	while(true)
        {
                System.out.println("1. Deposit");
                System.out.println("2. Withdarw");
                System.out.println("3. Balance");
                System.out.println("4. Exit");
                System.out.println("Enter ur choice");
                int ch = Integer.parseInt(ds.readLine());
                switch(ch)
                {
                        case 1: ob.deposit2();
                                break;
                        case 2: ob.withdraw2();
                                break;
                        case 3: ob.display2();
                                break;
                        case 4: System.exit(0);
                                break;
                        default : System.out.println("Enter correct choice");
                        break;
                }
           }
       }
 }
  • Add new comment

Comments

Featured Blog Posts

Convert Currency in Number to Words (Indian Rupees) - MS Excel
Foxpro Tutorial and Programs
Convert Currency in Number to Words in MS Word
Convert Currency in Number to Words (Indian Rupees) - Version 2
Best way to Use Rupee Symbol in Windows – Easy steps
Convert Currency in Number to Words - MS Access
Creating All in One Windows XP DVD with all Important Applications
RSS feed

© 2009-2025 Live to Learn.In

Terms of Use | Privacy Policy