-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBank.java
More file actions
48 lines (41 loc) · 1.01 KB
/
Bank.java
File metadata and controls
48 lines (41 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
44
45
46
47
48
class Bank {
String name;
int accno;
double p;
Bank(String name, int accno, double p) {
this.name = name;
this.accno = accno;
this.p = p;
}
void display() {
System.out.println("Name: " + name);
System.out.println("Account Number: " + accno);
System.out.println("Principal Amount: $" + p);
}
}
class Account extends Bank {
double amt;
Account(String name, int accno, double p, double amt) {
super(name, accno, p);
this.amt = amt;
}
void deposit(double amount) {
p = p + amount;
}
void withdraw(double amount) {
if (amount > p) {
System.out.println("INSUFFICIENT BALANCE");
} else {
p = p - amount;
if (p < 500) {
double penalty = (500 - p) / 10;
p = p - penalty;
}
}
}
@Override
void display() {
super.display();
System.out.println("Transaction Amount: $" + amt);
}
}