-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTestAccount.java
57 lines (49 loc) · 1.22 KB
/
TestAccount.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
//Java Program to demonstrate the working of a banking-system
//where we deposit and withdraw amount from our account.
//Creating an Account class which has deposit() and withdraw() methods
class Account{
int acc_no;
String name;
float amount;
// method to initialize objects
void insert(int a, String n, float amt){
acc_no = a;
name = n;
amount = amt;
}
// deposite method
void diposite(float amt){
amount = amount + amt;
System.out.println(amt+"deposited");
}
//withdraw method
void withdraw(float amt){
if(amount<amt){
System.out.println("Insufficient Balance");
}
else{
amount = amount - amt;
System.out.println(amt+"withdrawn");
}
}
// method to check the balance of the amount
void checkBalance(){
System.out.println("Balance is: "+amount);
}
// method to display the value of an objects
void display(){
System.out.println(acc_no+" "+name+" "+amount);
}
}
class TestAccount{
public static void main(String args[]){
Account a1 = new Account();
a1.insert(832345, "Kamrul", 1000);
a1.display();
a1.checkBalance();
a1.diposite(40000);
a1.checkBalance();
a1.withdraw(15000);
a1.checkBalance();
}
}