-
Notifications
You must be signed in to change notification settings - Fork 1
/
BankAccount.java
64 lines (60 loc) · 1.54 KB
/
BankAccount.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import java.util.Scanner;
public class BankAccount
{
String name,address,accnum;
double balance;
BankAccount(String n,String a,String ac,double b)
{
name=n;
address=a;
accnum=ac;
balance=b;
}
void deposit(double amt)
{
System.out.println("Enter the amount to be deposited:"+amt);
}
double withdraw(double am)
{
if(balance<2000.00)
{
System.out.println(" Low Balance:");
}
else
{
balance=balance-am;
}
return(balance);
}
double withdraw(double am1,char c)
{
if(balance<2000.00)
{
System.out.println("Withdrawal not possible:");
}
else
{
balance=balance-am1;
}
return balance;
}
void display()
{
System.out.println("Name of the account holder:"+name);
System.out.println("Address of the account holder:"+address);
System.out.println("Balance of the account holder:"+balance);
}
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the amount to be withdrawn:");
double x=sc.nextDouble();
BankAccount ob1=new BankAccount("abc","kolkata","hdfc45678",50000.00);
ob1.deposit(7000.00);
ob1.display();
ob1.withdraw(x);
ob1.display();
ob1.withdraw(x,'a');
ob1.display();
}
}