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 6 of 6

Thread: Problem With Bank + Atm Program please Help

  1. #1
    Junior Member
    Join Date
    Jun 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Problem With Bank + Atm Program please Help

    i m working on bank + atm project and i have to submtted on monday the account and bank class is working but in atm class i m very confused i want to add following methods in atm class
    withdrawmoney
    withdrawinstantmoney
    please suggest some ideas i m worried

    here is code for account class

    public class Account
    {
       private String number;
       private String owner;
       private String type;
       private int money;
       private int age;
        private String currentCard;
    	private String currentPIN;
        public Account(String number,String owner,String type,int money,int age,String currentCard,String currentPIN )
     
        {
            this.number=number;
            this.owner=owner;
            this.type=type;
            this.money=money;
            this.age=age;
            this.currentPIN=currentPIN;
            this.currentCard=currentCard;
     
    }
     
    public void setCard(String currentCard)
        {
            this.currentCard=currentCard;
        }
     
        public void setPIn(String currentPIN)
        {
            this.currentPIN=currentPIN;
        }
     
        public String getCard()
        {
            return currentCard;
        }
     
         public String getPin()
        {
            return currentPIN;
        }
     
     
        public String getNo()
        {
            return number;
        }
     
         public String getOnwer()
        {
            return owner;
        }
     
        public int getage()
        {
            return age;
        }
     
         public String getType()
        {
            return type;
        }
     
        public int getMoney()
        {
            return money;
        }
     
        public void setNo(String number)
        {
            this.number=number;
        }
     
        public void setOnwer(String Nowner)
        {
            this.owner=owner;
        }
     
        public void setType(String type)
        {
            this.type=type;
        }
     
        public void setMoney(int money)
        {
            this.money=money;
        }
     
        public void setAge(int age)
        {
            this.age=age;
        }
     
        public void print()
        {
            System.out.println("Number="+number);
            System.out.println("onwer="+owner);
            System.out.println("type="+type);
            System.out.println("money="+money);
            System.out.println("your age="+age);
            System.out.println("card="+currentCard);
            System.out.println("pin="+currentPIN);
        }


    here is code for Bank class
    import java.util.ArrayList;
    import java.util.Scanner;
    public class Bank
    {
     
        private ArrayList<Account> allAccounts;
        private Scanner readIn;
        public double deposit;
     
     
        public Bank()
        {
          allAccounts = new ArrayList<Account>();
            readIn = new Scanner(System.in);  
        }
     
        public void setDeposit(double d)
        {
            deposit = d;
        }
        public double getDeposit()
        {
            return deposit;
        }
        public void addAccount(String number,String owner,String type,int money,int age,String currentCard,String currentPIN)
        {                                                                                                                                                                                                                      
           Account a=new Account(number,owner,type,money,age,currentCard,currentPIN);
    allAccounts.add(a);
     
        }
        private boolean indexValid(int index)
        {
     
            boolean valid;
     
            if(index < 0) {
                System.out.println("Index cannot be negative: " + index);
                valid = false;
            }
            else if(index >= allAccounts.size()) {
                System.out.println("Index is too large: " + index);
                valid = false;
            }
            else {
                valid = true;
            }
            return valid;
        }
     
        public void closeAccount(int index) {
        	if(indexValid(index)) {
                allAccounts.remove(index);
            }
     
        }
        public void displayAcc(int index) {
           if(index >= 0 && index <allAccounts.size()) {
                Account newfilename = allAccounts.get(index);
    newfilename.print();
            }
     
        }
     
        public void displayAllAcc() {
        	for(Account theAccounts : allAccounts){
        		theAccounts.print();
        		System.out.println();
            }
        }
     
        public void accountSearch(String owner)
        {
            for(Account acc : allAccounts) {
                if(acc.getOnwer().contains(owner)) {
    //                 System.out.println(acc.getDetails());
                         acc.print();
                }
                else {
                     System.out.println("no account found");
                }
            }
        }
     
            public void depositMoney(String owner)
        {
            for(Account acc : allAccounts) {
                if(acc.getOnwer().contains(owner)) {
                    System.out.println(acc.getMoney()+getDeposit());
     
                }
     
        }
     
    }
     
    }


    the main problem is in atm class i m confused


    import java.util.Scanner;
    public class AtmMachine
    {
     
    	private Scanner input;
    	private Scanner readIn;
    	private Account theAccount;
    	private Bank theBank;
    	private String Card;
    	private String PIN;
    	private int withdrawal;
     
        public AtmMachine()
        {
            readIn = new Scanner(System.in);  
            input = new Scanner(System.in);
     
     
        }


    please suggest some solution so i can do this


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Problem With Bank + Atm Program please Help

    Can you describe what those methods are supposed to do? Their names give a simple definition, but what else would the methods need to do?
    What does "instantMoney" mean?
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Jun 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Problem With Bank + Atm Program please Help

    Quote Originally Posted by Norm View Post
    Can you describe what those methods are supposed to do? Their names give a simple definition, but what else would the methods need to do?
    What does "instantMoney" mean?
    withdraw method should extract money on user input

    instantMoney money should do following things

    if user press 1 we should get 100 rupees
    if press 2 we should get 500
    and so on

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Problem With Bank + Atm Program please Help

    Ok. Do you know the details of what each of those methods needs to do? For example: should the user's balance be checked and changed?
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Jun 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Problem With Bank + Atm Program please Help

    yes bro if user want to get money through atm class
    then it should display
    remaining balance

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Problem With Bank + Atm Program please Help

    I think there is more that needs to be done in the method than display the balance.
    Make a list of the steps that the method should do.
    When that list is finished, try writing the code to do the steps in the list.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Bank Program
    By Paul1966 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: April 30th, 2013, 05:43 PM
  2. ATM program machine help
    By karolek0901 in forum What's Wrong With My Code?
    Replies: 0
    Last Post: November 26th, 2012, 06:01 PM
  3. help with my bank account program
    By captain_turkiye in forum Object Oriented Programming
    Replies: 3
    Last Post: October 14th, 2011, 10:33 AM
  4. help! Atm bank machine problem
    By galva in forum What's Wrong With My Code?
    Replies: 7
    Last Post: January 6th, 2011, 12:08 PM
  5. How to delete records from a Random-Access File?
    By keith in forum File I/O & Other I/O Streams
    Replies: 10
    Last Post: March 31st, 2009, 11:40 AM