Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: banking system program of a person having two accounts namely saving account and checking acccount.

  1. #1
    Junior Member
    Join Date
    Dec 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Unhappy banking system program of a person having two accounts namely saving account and checking acccount.

    import java.util.*;
    class data
    {
    long wbal,debal;
    long checkbal=1000l,savbal=1000l;
    long accno=1234567890,acountnum;
    public void name()
    {
    String firstname,lastname;
    firstname="vivek";
    lastname="bhardwaj";
    System.out.println("the name of acountee is "+firstname);
    System.out.println(""+lastname);
    }
    public void transaction()
    {
    System.out.println("enter your account no");
    Scanner obj=new Scanner(System.in);
    acountnum=obj.nextLong();
    if(acountnum==accno)
    {
    int val;

    Scanner bj=new Scanner(System.in);
    System.out.println("enter the choice:");

    try
    {
    char ch=bj.nextChar();
    Switch(ch)
    {

    case 's': { System.out.println(" this is your saving account");
    System.out.println("what you want to do ?");
    System.out.println("press 0 for withdrawal ");
    Scanner obj1=new Scanner(System.in);
    val=obj1.nextInt();

    if(val==0)
    {
    System.out.println("enter the amount for withdrawl");
    Scanner obj2=new Scanner(System.in);
    wbal=obj2.nextLong();

    if(wbal<=savbal)
    {
    savbal=savbal-wbal;
    System.out.println("the remaining balance is"+savbal);
    }
    else
    {
    System.exit(0);
    }
    }
    else
    {
    System.out.println("enter the amount to be deposited");
    Scanner obj3=new Scanner(System.in);
    debal=obj3.nextLong();
    savbal=savbal+debal;
    System.out.println("current balnce is "+savbal);
    }}

    break;


    case 'c': System.out.println(" this is your checking account");
    System.out.println("what you want to do ?");
    System.out.println("press 0 for withdrawal ");
    Scanner obj4=new Scanner(System.in);
    val=obj4.nextInt();

    if(val==0)
    {
    System.out.println("enter the amount for withdrawl");
    Scanner obj5=new Scanner(System.in);
    wbal=obj5.nextLong();

    if(wbal<=checkbal)
    {
    checkbal=checkbal-wbal;
    System.out.println("the remaining balance is"+checkbal);
    }
    else
    {
    System.exit(0);
    }}
    else
    {
    System.out.println("enter the amount to be deposited");
    Scanner obj6=new Scanner(System.in);
    debal=obj6.nextLong();
    checkbal=checkbal+debal;
    System.out.println("current balnce is "+checkbal);
    }
    }

    break;

    default: System.exit(0);
    }
    }
    catch (Exception e)
    {
    System.out.println("");
    }
    }
    else
    {
    System.exit(0);
    }
    }
    }
    class banksys
    {
    public static void main(String args[])
    {
    data d1=new data();
    d1.name();
    d1.transaction();
    }
    }


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,029
    Thanks
    52
    Thanked 2,278 Times in 2,249 Posts

    Default Re: banking system program of a person having two accounts namely saving account and checking acccount.

    Please edit your post and wrap your code with code tags:
    [code=java]
    YOUR CODE HERE
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Dec 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: banking system program of a person having two accounts namely saving account and checking acccount.

    please help me
    how to use switch using charcter input ???

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    21,029
    Thanks
    52
    Thanked 2,278 Times in 2,249 Posts

    Default Re: banking system program of a person having two accounts namely saving account and checking acccount.

    Please edit your post and wrap your code with code tags:
    [code=java]
    YOUR CODE HERE
    [/code]
    to get highlighting and preserve formatting.

    The code needs to be formatted to be readable. The posted code is hard to read.
    how to use switch using charcter
    See the tutorial on how to use the switch statement: The switch Statement (The Java™ Tutorials > Learning the Java Language > Language Basics)
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Checking Account class, need help
    By alex067 in forum Object Oriented Programming
    Replies: 10
    Last Post: September 23rd, 2012, 10:07 PM
  2. Need some help with my Banking program
    By bankston13 in forum What's Wrong With My Code?
    Replies: 7
    Last Post: September 17th, 2012, 09:04 PM
  3. Banking System UML Class Diagram in to code.
    By djl1990 in forum Java Theory & Questions
    Replies: 2
    Last Post: October 13th, 2011, 11:55 AM
  4. banking system
    By preeti in forum Java Theory & Questions
    Replies: 3
    Last Post: August 11th, 2011, 01:25 PM
  5. Simple Banking System
    By ShadowKing98 in forum Java Theory & Questions
    Replies: 7
    Last Post: April 12th, 2011, 04:26 AM