-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBank.java
More file actions
43 lines (39 loc) · 1.01 KB
/
Bank.java
File metadata and controls
43 lines (39 loc) · 1.01 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
33
34
35
36
37
38
39
40
41
42
43
import java.util.Scanner;
class Account
{
String accountHolderr;
double balancee;
Account(String accountHolder,double balance ){
balancee = balance;
accountHolderr = accountHolder;
}
void debit(int amount) {
if(amount>balancee)
System.out.println("Insufficient Money");
else
balancee -= amount;
System.out.println("Debited Amount "+amount+"Your Current Balance : "+balancee);
}
void credit(int amount) {
balancee += amount;
System.out.println("Credited Amount: "+amount+"Your current Balance : "+balancee);
}
void checkBalance(){
System.out.println("Account Holder Name : "+accountHolderr);
System.out.println("Balance : "+balancee);
}
}
public class Bank {
public static void main(String[] args) {
Account account1 = new Account("vamsi",100);
Account account2 = new Account("krishna",300);
account1.checkBalance();
account2.checkBalance();
account1.debit(500);
account1.credit(1500);
account2.debit(500);
account2.credit(1000);
account1.checkBalance();
account2.checkBalance();
}
}