Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  Bank.java
Language: JAVA
Code:
import java.util.*;

class Main

{

Scanner a=new Scanner(System.in);

int acno;

String name;

int balance;

void details()

{

acno=123456;

name="Arun";

balance=123890;

}

void withdrawl()

{

int w;

System.out.println("Enter withdrawl amount");

w=a.nextInt();

if(w>balance)

{

System.out.println("Insufficient balance");

}

else

{

balance=balance-w;

System.out.println("Remaining amount is"+balance);

}

}

void deposit()

{

int d;

System.out.println("Enter amount to be deposited");

d=a.nextInt();

balance=balance+d;

System.out.println("Balance is "+balance);

}

void enquiry()

{

System.out.println("Account number :"+acno);

System.out.println("Name :"+name);

System.out.println("Balance :"+balance);

}

}

class Bank

{

public static void main(String args[])

{

int ch=0;

Main obj=new Main();
 
while(ch!=4)

{
 
System.out.println("Enter your choice");

System.out.println("1.Withdrawl");

System.out.println("2.Deposit");

System.out.println("3.Enquiry");

System.out.println("4.Exit");

 Scanner s=new Scanner(System.in);

 ch=s.nextInt();

switch(ch)

{

case 1:

obj.withdrawl();

break;

case 2:

obj.deposit();

break;

case 3:

obj.enquiry();

break;

case 4:

break;

default: System.out.println("Invalid choice");

}

}

}

}
Comments: