Pages

ATM machine program (Sample JAVA program question)

Write a program that design ATM machine with extra function for EXIM BANK

 

1st Shot

2nd Shot
 
3rd


 Study or Copy and paste below codes:


import java.util.Scanner;
class assignment
{
public static void main(String [] args) {
Scanner take=new Scanner(System.in);

System.out.println("***********************************************************************");
System.out.println("***********************************************************************");
System.out.println("**********************WELCOME TO EXIM BANK*****************************");
System.out.println();
System.out.println();

System.out.println(" \t    Please press \"1\" to continue Or \"0\" to quit");

//verification to continue
for(int i = 1; i>0;i++)
 {
 int go = take.nextInt();
 if (go == 1){
 break;
 }
 else if (go == 0){
 System.out.println("You have choosen to exit, Bye Bye Bye...");
 System.exit(0);
 break;
 }

 else {
 System.out.println("\t \t    You hAve entered invalid choice," + "\n\r" + "****************************Please Try again***************************");
 continue;
 }
}


System.out.println("Now you can Open an Account");
System.out.println("");


//Entering First name
System.out.print("Enter your firstname: ");
String fname = take.next();
System.out.println("");


//Entering Second name
System.out.print("Enter your middlename: ");
String mname = take.next();

//Entering last name
System.out.println("");
System.out.print("Enter your lastname: ");
String lname = take.next();

//Entering Sex
System.out.println("");
System.out.print("Enter your Gender: ");
String sex = take.next();

//Entering Account number
System.out.println("");
System.out.print("Enter your Account no: ");
String an = take.next();

//Entering Password/pin
System.out.println("");
System.out.print("Enter your Password: ");
int pin = take.nextInt();

//Deposit initial amount
System.out.println("");
System.out.print("Enter your Starting amount: ");
int balance = take.nextInt();

//Display
System.out.println("***********************************************************************");
   /* if (sex == "male"){
   System.out.println("Welcome, Mr "+ fname + " " + mname + " " +lname);
   }
   else if(sex == "female"){
   System.out.println("\t\t Welcome, Miss "+ fname + " " + mname + " " +lname);
   }
   else {
   System.out.println("\t \t WelcomE, "+ fname + " " + mname + " " +lname);
   } */
System.out.println("\t\t\t    Welcome, "+ fname );

System.out.println("********** Now, you have successful registered with EXIM Bank *********");
System.out.println("");
System.out.print("Your account name is: "+ lname + " " + mname + " " +fname);
System.out.println("");
System.out.println("Your account number is: "+ an);
System.out.println("");
System.out.println("Your account balance is: "+ balance);

//Choice
 for(int x = 1; x<=6; x++)
 {
  if(x == 5){
   System.out.println();
   System.out.println();
   System.out.println("***********************************************************************");
   System.out.println("********** Your session has expired, Please try again later ***********");
   System.exit(0);
   break;
   }
 System.out.println();
 System.out.println("Choose what you want to perform");
 System.out.println("1. Deposit"+"\n" +"2. Withdraw"+"\n" +"3. Check balance"+"\n" +"4. To Exit");

/*int choice = take.nextInt();
String choice = take.next();
if (choice!= 1 ||choice!=2 ||choice!=3||choice!= 4)
{
System.out.println("Please use the given numbers above");
String choice = take.next();
if (choice!= 1 ||choice!=2 ||choice!=3||choice!= 4)
{
System.out.println("Sorry, no Service at the moment");
}
}
*/

int ch = take.nextInt();
switch (ch) {
case 1: 

 System.out.println("Enter the amount: ");
 int deposit = take.nextInt();

  for(int d = 1; d <=5; d++)
  {
  System.out.println("Verify password please");
  int password = take.nextInt();
   if(password == pin)
    {
       balance+=deposit;
        System.out.println("You have successful deposit "+deposit +"\n Your new account balance is: "+ balance);
    break;
    }
    else if(d == 3)
    {
    System.out.println();
    System.out.println();
    System.out.println("***********************************************************************");
    System.out.println("************ You have tried enough, Please try again later ************");
    System.exit(0);
    break;
   
    }


  }
 break;
case 2: System.out.print("Enter the amount: ");
 for(int d = 1; d <=8; d++)
 {
    int withdraw = take.nextInt();
   if (balance>withdraw)
   {
   balance-=withdraw;
   break;
   }
   else if(d < 5)
   {
   System.out.println("Please enter the amount that is low than  your balance "+balance+" Tsh");
   }
   else
   {
   System.out.println();
   System.out.println();
   System.out.println("***********************************************************************");
   System.out.println("******* You dont have sufficient amount, Please try again later *******");
   System.out.println("*****************Your account balance is: "+balance+" Tsh"+"******************");
   System.exit(0);
   break;
   }


 }
//------------------------------------------------------------------------------------------
   for(int d = 1; d <=5; d++)
  {

   System.out.println("Verify password please");
 
 
 
   int password1 = take.nextInt();
   if(password1 == pin)
    {
        System.out.println("Verification successful");       
             System.out.println("You have successful withdraw  Your new account balance is: "+ balance);

    break;
    }
    else if(d == 3)
    {
    System.out.println();
    System.out.println();
    System.out.println("***********************************************************************");
    System.out.println("************ You have tried enough, Please try again later ************");
    System.exit(0);
    break;
     }
   

    else if(d < 3)
    {
    System.out.println();
    System.out.println();
  
    System.out.println("************ You have entered invalid password,  try again ************");
  
  
     }
  }
   break;
case 3:

  for(int d = 1; d <=5; d++)
  {
   System.out.println("Verify password please");
   int password2 = take.nextInt();
   if(password2 == pin){
   System.out.println("Verification successful");
    System.out.println("\n Your account balance is: "+ balance);
   break;
   }
   else if(d >= 3)
   {
   System.out.println("Failed to verify your password, try again later");
   System.exit(0);
   }

  }
   break;
case 4: System.out.println("Thank you for using EXIM BANK");
 System.exit(0);
 break;
 default:
 System.out.print("Wrong choice, Please try again");
 

  /*
  System.out.print("Wrong choice, For your security you have logged out, please login to try again");
  System.out.println("***********************************************************************");
  System.exit(0);

  */

}
}


}
}
 

1 comment:

  1. Welcome! Washox Blog: Atm Machine Program (Sample Java Program Question) >>>>> Download Now

    >>>>> Download Full

    Welcome! Washox Blog: Atm Machine Program (Sample Java Program Question) >>>>> Download LINK

    >>>>> Download Now

    Welcome! Washox Blog: Atm Machine Program (Sample Java Program Question) >>>>> Download Full

    >>>>> Download LINK dI

    ReplyDelete