what is the problem in ATM machine program

Posted by Have alook on Stack Overflow See other posts from Stack Overflow or by Have alook
Published on 2010-04-03T13:18:19Z Indexed on 2010/04/03 13:23 UTC
Read the original article Hit count: 503

Filed under:

in this prigramm when the account number is uncorrect it should display a message to write a gain but when i wrote a gain by corrrect account number always it diplay the result of first account also there is aproblem in PIN number ,the use have only three time to try if he enter wrong numbe and if enter three times wrong it should stop the program but it complete to the last part I dont know why pleas help me

this is my proram

import java.util.*; class assignment2_70307{ public static void main(String args[]){

Scanner m=new Scanner(System.in);

int i; i=0; int [] accountNo =new int[7] ;//declear the Accont number array accountNo [0] =1111; accountNo [1] =2222; accountNo [2] =3333; accountNo [3] =4444; accountNo [4] =5555; accountNo [5] =6666; accountNo [6] =7777;

int [] PINno =new int[7]; //declear the PIN number array PINno [0] =1234; PINno [1] =5678; PINno [2] =9874; PINno [3] =6523; PINno [4] =1236; PINno [5] =4569; PINno [6] =8521;

String [] CusomerNm =new String[7]; //dclear the customer name CusomerNm [0] ="Ali"; CusomerNm [1] ="Ahmed"; CusomerNm [2] ="Amal"; CusomerNm [3] ="Said"; CusomerNm [4] ="Rashid"; CusomerNm [5] ="Fatema"; CusomerNm [6] ="Mariam";

double [] Balance =new double[7]; //declear the Balane array Balance [0] =100.50; Balance [1] =5123.00; Balance [2] =12.00; Balance [3] =4569.00; Balance [4] =1020.25; Balance [5] =0.00; Balance [6] =44.10;

System.out.println("Wellcome to mini ATM Machine");

int accountno,pino; accountno=0; pino=0; System.out.println("Please Enter your account number: or -1 to stop" ); accountno=m.nextInt();

    if (accountno==accountNo[0])
    System.out.print("Customer Name: "+CusomerNm [0]+ "\n" );
    else if (accountno==accountNo[1])
    System.out.print("Customer Name: "+CusomerNm [1]+ "\n" );
    else if (accountno==accountNo[2])
    System.out.print("Customer Name: "+CusomerNm [2]+ "\n" );
    else if (accountno==accountNo[3])
    System.out.print("Customer Name: "+CusomerNm [3]+ "\n" );
    else if (accountno==accountNo[4])
    System.out.print("Customer Name: "+CusomerNm [4]+ "\n" );
    else if (accountno==accountNo[5])
    System.out.print("Customer Name: "+CusomerNm [5]+ "\n" );
    else if (accountno==accountNo[6])
    System.out.print("Customer Name: "+CusomerNm [6]+ "\n" );
//  else if (accountNo[0]==-1)
        //break;            
    else {


    System.out.println("The account dose not exist,please try again");
    //accountNo[i]=m.nextInt();
    accountno=m.nextInt();
            if(accountNo[i]==accountno)

            System.out.println("Customer Name: "+CusomerNm[i] );
            else 
            System.out.println("The account dose not exist,please try again");
            accountno=m.nextInt();
            System.out.println("Customer Name: "+CusomerNm[i] );


    }




        System.out.print("Enter your PIN number:");
        PINno[i]=m.nextInt();

            if(PINno[i]==1234)
            {
            System.out.println(PINno[i]);
            System.out.println("Balance:"+Balance [0]+ "Rial");
            //return 0;
            }
            else    if(PINno[i]==5678)
            {
            System.out.println(PINno[i]);
            System.out.println("Balance:"+Balance [1]+ "Rial");
        //  return 1;
            }

            else    if(PINno[i]==9874)
            {
            System.out.println(PINno[i]);
            System.out.println("Balance:"+Balance [2]+ "Rial");
        //  return 2;
            }

            else    if(PINno[i]==6523)
            {
            System.out.println(PINno[i]);
            System.out.println("Balance:"+Balance [3]+ "Rial");
        //  return 3;
            }

            else    if(PINno[i]==1236)
            {
            System.out.println(PINno[i]);
            System.out.println("Balance:"+Balance [4]+ "Rial");
        //  return 4;
            }

            else    if(PINno[i]==4569)
            {
            System.out.println(PINno[i]);
            System.out.println("Balance:"+Balance [5]+ "Rial");
        //  return 5;
            }

            else    if(PINno[i]==8521)
            {
            System.out.println(PINno[i]);
            System.out.println("Balance:"+Balance [6]+ "Rial");
        //  return 6;
            }


            else
        {System.out.println("try again");
            //return 7;
            //if its wrong u can enter PIN number three times only
            for( i=0;i<2;i++)
            {
            System.out.println("enter pin again");
        PINno[i]=m.nextInt();
            String ss;
            //ss = "MAnal";
        //  goto ss ;
            }  

}

//ss = "m"; int x; x=0; System.out.println("Enter the option from the list /n 1.Deposit /n 2.Withdraw /n 3.Balance"); x=m.nextInt();

double balance,amount; balance=0; amount=0; double deposit ,Withdraw; deposit=0; Withdraw=0;

    if (x==1){
    System.out.println("Enter the amont you want to deposit:"+amount);
            amount=m.nextDouble();

                    Balance [i]=Balance [i]+amount;
                    System.out.println("your balance ="+Balance [i]);
                    }


    else if (x==2)
    {
    System.out.println("Enter the amont to withdraw:");
    amount=m.nextDouble();
    System.out.print(amount);
     if(Withdraw<=Balance [i])
        {
        Balance [i]=Balance [i]-amount;
        System.out.println("your balance ="+Balance [i]);
        }
        else
        {
        System.out.println("sorry,please enter the amont less or equal your balance");
        System.out.println(Balance [i]);
        }
        }

        else
        {
            if(x==1)
            {
            Balance [i]=Balance [i]+deposit;
            System.out.println("your current  balance is :" +Balance [i]);
            }

            else
            {
        Balance [i]=Balance [i]-Withdraw;
            System.out.println("your current  balance is :"+Balance [i]);
                }


System.out.println("Thank you");



    //  err()

} }

            }

© Stack Overflow or respective owner

Related posts about java