You are on page 1of 3

import java.util.

*;

class Bank
{
Scanner t=new Scanner(System.in);
//Declarations//
int f=0;
String c_name,add;
double bal,a_no,phone;

String[]address={"Kanyadi","Ujire","Dharmasthala","Ujire","Dharmasthala","Puttur","
Ujire","Ujire","Kayarthadka","Ujire"};
double[]phno={98598,85888,96698,99862,985549,81488,985225,68522,98872,27852};
double[]balance={10000,15000,15000,6000,4923,8579,5862,8695,7485};
double[]acc_no={12345,23456,34567,45678,56789,67890,78901,89012,90123,01234};

String[]cname={"Amare","Vivek","Ashwin","Smitha","Anvitha","Ramya","Harsha","Shrees
ha","Prathwin","Amruth"};

double[]password={200202,20223,200225,200222,200224,200227,200226,200216,200219,200
284};

//Login Validation//
Bank(double a,double p)
{
for(int i=0;i<10;i++)
{
if(a==acc_no[i]&&p==password[i])
{
System.out.println("Login Successful");
f=1;
bal=balance[i];
c_name=cname[i];
a_no=acc_no[i];
add=address[i];
phone=phno[i];
}
}
if(f!=1)
{
System.out.println("Login Failed. Try again...");
}
}

//Input Checking//
void Input()
{
double acc_d,pass_d;
System.out.println("Please Login to continue the process \n");
System.out.print("Enter your Account Number: ");
acc_d=t.nextDouble();
//Only password entry//
System.out.print("Enter the password:");
pass_d=t.nextDouble();
}

//Deposit Process//
void Deposit()
{
System.out.print("Enter Deposit Amount: ");
double deposit=t.nextDouble();
bal=bal+deposit;
System.out.print("Deposit of Rs."+deposit+" is successful");
}

//Withdraw Process//
void Withdraw()
{
int status=Proceed();
if(status==1)
{
System.out.print("Enter the amount: ");
double withdraw=t.nextDouble();
bal=bal-withdraw;
System.out.print("Withdraw of Rs."+withdraw+" successful");
}
else
{
System.out.println("Insufficient Account Balance");
}
}

//To check minimum balance limit//


int Proceed()
{
if(bal>500)
return(1);
else
return(0);
}

//To Display processed transaction and customer details//


void Display()
{
//for(i=0;i<10;i++)//
System.out.println("Customer name: "+c_name);
System.out.println("Account Number: "+a_no);
System.out.println("Account Balance: "+bal);
System.out.println("Phone Number: "+phone);
System.out.println("Address: "+add);
}
}

public class Transaction


{
public static void main(String ar[])
{
Scanner I=new Scanner(System.in);
int n=1;
double acc,pass;

/*System.out.println("Please Login to continue the process \n");


System.out.print("Enter Account Number: ");
acc=I.nextDouble();*/

Bank b1=new Input();


b1.Input();
acc=b1.acc_d;
pass=b1.pass_d;

/*Bank b=new Bank(acc);*/

Bank b2=new Bank(acc,pass);


int f1=b2.f;
if(f1==1)
{
System.out.println("Welcome to Your_Bank");
do
{
System.out.println("To continue choose any transaction from the
list");
System.out.println("Enter\n 1-Deposit\n 2-Withdraw\n 3-Check
Balance\n 4-End Transaction");
int choice=I.nextInt();
switch(choice)
{
case 1: b2.Deposit();
b2.Display();
break;
case 2: b2.Withdraw();
b2.Display();
break;
case 3: b2.Display();
break;
case 4:n=0;
System.out.println("Please wait...");
System.out.println("Logging out...");
break;
default:System.out.println("Invalid Choice");
}
}while(n==1);
System.out.println("----Successfully Logged out----");
System.out.println("----Thank you for visiting----");
}
}
}

You might also like