public class naming
{
    private String name ;
    private String address ;
    private int idCard ;
    private int firstMoney;


    public naming()
    {
        name="";
        address="";
        idCard=0;
        firstMoney=0;


    }

    public naming(String n , String ad ,int id , int fm )
    {
        name=n;
        address=ad;
        idCard=id;
        firstMoney=fm;


    }


    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getAddress() {
        return address;
    }
    public void setAddress(String address) {
        this.address = address;
    }
    public int getIdCard() {
        return idCard;
    }
    public void setIdCard(int idCard) {
        this.idCard = idCard;
    }
    public int getFirstMoney() {
        return firstMoney;
    }
    public void setFirstMoney(int firstMoney) {
        this.firstMoney = firstMoney;
    }



}




public class deposit extends naming 
{
    private int depositMoney;

    public deposit(int depositMoney) {
        super();
        this.depositMoney = depositMoney;
    }

    public int getDepositMoney() {
        return depositMoney;
    }

    public void setDepositMoney(int depositMoney) {
        this.depositMoney = depositMoney;
    }


}





public class withdraw extends naming
{
    private int withdrawMoney;

    public withdraw(int withdrawMoney) {
        super();
        this.withdrawMoney = withdrawMoney;
    }

    public int getWithdrawMoney() {
        return withdrawMoney;
    }

    public void setWithdrawMoney(int withdrawMoney) {
        this.withdrawMoney = withdrawMoney;
    }



}





public class admin 
{
    private static String userName="ali";
    private static String Password="ali";
    private String Login;
    private String Pass;
    public admin(String login, String pass) {

        Login = login;
        Pass = pass;
    }
    public static String getUserName() {
        return userName;
    }


    public static String getPassword() {
        return Password;
    }


    public String getLogin() {
        return Login;
    }


    public String getPass() {
        return Pass;
    }




}




import java.util.Scanner;

public class banking
{


     public static String getLogin()
     {
         Scanner input = new Scanner(System.in);
         System.out.println("enter the username");
         return input.nextLine();

     }
     public static String getPass()
     {
         Scanner input = new Scanner (System.in);
         System.out.println("enter the password");
         return input.nextLine();
     }

}



import java.util.Scanner ;
public class Menu 
{

    public static void  show()

    { 

        System.out.println("**********************************");
        System.out.println("**********BANKING SYSTEM**********");
        System.out.println("**********************************");
        System.out.println("1 : ADMIN");
        System.out.println("2 : DEPOSIT");
        System.out.println("3 : Withdraw");

    }

public static void  adminShow()

    { 


        System.out.println("1 : New Account");
        System.out.println("2 : Show Accounts");

    }


    public static String  getName()
    {
        Scanner input = new Scanner (System.in);
        System.out.println("enter your name ");

        return input.nextLine();
    }

    public static String getAddress()
    {
        Scanner input = new Scanner (System.in);
        System.out.println("enter your address  ");

        return input.nextLine();
    }

    public static int getIdCard()
    {
        Scanner input = new Scanner (System.in);
        System.out.println("enter your id card number   ");

        return input.nextInt();
    }

    public static int getFirstMoney()
    {
        Scanner input = new Scanner (System.in);
        System.out.println("enter your first money   ");

        return input.nextInt();
    }

    public static int getDepositMoney()
    {
        Scanner input = new Scanner (System.in);
        System.out.println("enter your deposti money    ");

        return input.nextInt();
    }

    public static int  getWithdrawMoney()
    {
        Scanner input = new Scanner (System.in);
        System.out.println("enter your withdraw  money    ");

        return input.nextInt();
    }

    public static void viewDetails(naming i)
    {
        System.out.println("NAME :" + i.getName());
        System.out.println("ADDRESS :" + i.getAddress());
        System.out.println("ID card # :" + i.getIdCard());
        System.out.println("First time Money : " + i.getFirstMoney());


    }

}




import java.util.Scanner;

public class Whole {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub

        int choice = 0;
        int choice1 = 0;
        int index = 0;
        int accountNo = 0 ;
        naming[] accounts = new naming[10];

        Scanner input = new Scanner(System.in);
        Menu m = new Menu();
        m.show();
        System.out.println("enter your choice");
        choice = input.nextInt();

        switch (choice) {
        case 1: {

            if (banking.getLogin().equals(admin.getUserName())
                    && banking.getPass().equals(admin.getPassword())) {
                m.adminShow();
                System.out.println("enter your choice");
                choice1 = input.nextInt();
                switch (choice1) {
                case 1: {
                    if (index < 10) {
                        accounts[index] = new naming(Menu.getName(),
                                Menu.getAddress(), Menu.getIdCard(),
                                Menu.getFirstMoney());
                        index++;
                    } else {
                        System.out.println("full");
                    }

                    m.adminShow();
                    System.out.println("enter your choice");
                    choice1 = input.nextInt();
                }

                case 2: {
                    if (index > 0) {
                        for (int i = 0; i < index; i++) {
                            Menu.viewDetails(accounts[i]);
                            System.out.println("\n accounts # " + (i + 0));
                            System.out.println("------------------------");
                        }
                        System.out.println("------------------------");
                    } else {
                        System.out.println("No Car Found!");
                    }

                }

                }

            }

        }

        case 2 :
        {   System.out.println("enter your account number");
            accountNo = input.nextInt();
            index = accountNo ;

            accounts[index]= new  deposit (Menu.getDepositMoney());

here i dont know how to update the firstmoney by adding the deposit money and displaying it ???

        }

        }

    }

}

Welcome to DaniWeb
It looks like your class structure is wrong.
Your "naming" class looks like a customer or client Account, in which case a deposit or a withdrawal should not extend naming because they are not a "kind of" naming.
A deposit or withdrawal basically needs two things: an amount of money to deposit/withdraw, and an Account where the money is to be deposited/withdrawn.

ps In Java it is normal to start all class names witha capital letter.

You mean to say that i should make another class for accounts in whiche there will be variables of total amount , deposit and withdraw then making thier own object array .but then how i will relate both class ??

Personally I would think along the lines of an Account class that has name/address/id/balance as its members, and a Deposit class that has an Account and an amount as its members. Similarly for Withdrawal. I would have a list of Accounts and a separate list of Deposits/Withdrawals. Maybe each Account should also have its own lists of Ds and Ws - that depends on where this may go next.

Before getting too far into Java code, try writing some typical data values down, and simulate a deposit and a withdrawal or two on paper - that will help you see what classes and lists of things you will need.

i understood the whole thing but i didnt understand the thing you are saying about deposit calss account and account as its member can u show a little demo code ???

Just something simple like...

class Deposit {
   Account account;
   int amount;
    // constructor needs an Account and an amount to populate this data...
public class deposit
{
    private int depositMoney;
    Account account ;




    public deposit(int depositMoney, Account account) {
        super();
        this.depositMoney = depositMoney;
        this.account = account;
    }

    public int getDepositMoney() {
        return depositMoney;
    }

    public void setDepositMoney(int depositMoney) {
        this.depositMoney = depositMoney;
    }


}

but i dont know how to use it in main ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.