-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBankAccount.java
More file actions
32 lines (32 loc) · 1.1 KB
/
BankAccount.java
File metadata and controls
32 lines (32 loc) · 1.1 KB
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
//User Bank Account class
public class BankAccount{
private double balance;
//It is used to initialize the account with some money
public BankAccount(double IBalance) {
balance = IBalance;
}
//It is used to store the Current balance
public double getBalance(){
return balance;
}
//Method for deposit the money in account
public void deposit(double amount){
//here we use if else condition because there are two situation either successfull or failed.
if(amount>0){
balance+=amount;
System.out.println("Deposit Successful.");
}else{
System.out.println("Inavalid Deposit. ");
}
}
//Method for withdrawal from the account
public void withdraw(double amount){
//here we use if else condition because there are two situation either successfull or failed.
if(amount<=balance){
balance-=amount;
System.out.println("Withdrawal Successfull.");
}else{
System.out.println("Insufficient amount");
}
}
}