Ask Question

Name:
Title:
Your Question:

Answer Question

Name:
Your Answer:
User Submitted Source Code!


Description:
  DE1
Language: JAVA
Code:
import java.util.*;
class Bank
{
String cus_name;
int accno;
String acctype;
int balance;
int d;
int with;
Bank(String cname, int acno, String atype, int bal)
{
cus_name=cname;
accno=acno;
acctype=atype;
balance=bal;
}

void deposit()
{
balance=balance+d;
System.out.println("New balance is " +balance);
}

void withdraw()
{
balance=balance-with;
if(balance<1000)
{
System.out.println("Falling short of cash. Please withdraw less amount");
}
else{
System.out.println("Withdraw successfull");
System.out.println("Current balance is" +balance);
}
}

void display()
{
System.out.println("Account no " +accno);
System.out.println("Customer name " +cus_name);
System.out.println("Account type" +acctype);
System.out.println("Balance amount" +balance);
}


}

class DE1
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter customer name");
String c=sc.nextLine();
System.out.println("Enter customer accountno");
int ac=sc.nextInt();
System.out.println("Enter customer accounttype");
String c1=sc.nextLine();
System.out.println("Enter balance amount greater than 1000");
int b1=sc.nextInt();
Bank b=new Bank(c,ac,c1,b1);
System.out.println("Enter your choice");
System.out.println("1. Deposit an amount");
System.out.println("2. Withdraw an amount");
System.out.println("3. Display customer details");
System.out.println("4. Exit");
int f1=sc.nextInt();
sc.close();
switch(f1)
{
case 1:
b.deposit();
break;
case 2:
b.withdraw();
break;
case 3:
b.display();
break;
case 4:
System.exit(0);
break;
}


}
}
     
Comments: