package onlinebanking;
import java.util.Scanner;

/**
 *
 * @author Lenovo
 */
public class OnlineBanking {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        BankAccount obj = new BankAccount("CustomerNameAA","ABC1234");
        obj.Menu();
        
    }
    
}
class BankAccount
{
    int Balance;
    int Last_Transaction;
    String Accountholder_Name;
    String Account_Id;
    
    BankAccount(String aname,String aid)
    {
        Accountholder_Name = aname;
        Account_Id = aid;
    }
    
    void Deposits(int amount)
    {
        if(amount!=0)
        {
            Balance = Balance + amount;
            Last_Transaction = amount;
        }
    }
    void Withdrawal(int amount)
    {
        if(amount!=0)
        {
            Balance = Balance - amount;
            Last_Transaction = -amount;
        }
    }
    void TraceLast_Transaction()
    {
        if(Last_Transaction > 0)
        {
            System.out.println("Amount Deposited: "+Last_Transaction);
        }
        else if(Last_Transaction < 0)
        {
            System.out.println("Amount Withdrawn: "+Math.abs(Last_Transaction));
        }
        else
        {
            System.out.println("No recent transaction occured");
        }
        
    }
    void Menu()
    {
       char option='\0';
       Scanner scanner = new Scanner(System.in);
       System.out.println("Welcome "+Accountholder_Name);
       System.out.println("Your ID is "+Account_Id);
       System.out.println("\n");
       System.out.println("A. Check Existence Balance");
       System.out.println("B. Deposit");
       System.out.println("C. Withdraw");
       System.out.println("D. Recent_Transaction");
       System.out.println("E. Exit");
       
       do
       {
           System.out.println(" This banking system is totally SECURED!!!");
           System.out.println("Enter your Option");
           System.out.println("------------------------------------------");
           option = scanner.next().charAt(0);
           System.out.println("\n");
           
           switch(option)
           {
               case 'A':
                   System.out.println("--------------------------------------");
                   System.out.println("Current Balance: = "+Balance);
                   System.out.println("--------------------------------------");
                   System.out.println("\n");
                   break;
                   
               case 'B':
                   System.out.println("--------------------------------------");
                   System.out.println("Enter an amount that is to be deposited:");
                   System.out.println("--------------------------------------");
                   int amount1 = scanner.nextInt();
                   Deposits(amount1);
                   System.out.println("\n");
                   break;
                   
               case 'C':
                   System.out.println("--------------------------------------");
                   System.out.println("Enter an amount to withdraw:");
                   System.out.println("--------------------------------------");
                   int amount2 = scanner.nextInt();
                   Withdrawal(amount2);
                   System.out.println("\n");
                   break;
                 
               case 'D':
                   System.out.println("--------------------------------------");
                   TraceLast_Transaction();
                   System.out.println("--------------------------------------");
                   System.out.println("\n");
                   break;
                   
               case 'E':
                   System.out.println("--------------------------------------");
                   System.out.println("Thank you");
                   System.out.println("--------------------------------------");
                   
               default:
                   System.out.println("Invalid!! Please Try Again");
                   break;
                   
                   
               
           }
          
           
           
           
       }while(option!= 'E');
       
       System.out.println("Thank you for using our services");
       
    }
    
    
}
