-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBank.java
More file actions
58 lines (49 loc) · 1.17 KB
/
Bank.java
File metadata and controls
58 lines (49 loc) · 1.17 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
49
50
51
52
53
54
55
56
57
58
import java.util.Scanner;
public class Bank {
private String name;
private String Accountno;
private String type;
private double balance;
static double rate;//no need to crate object direct call
Bank(){
name="Alax";
Accountno="None";
type="None";
balance=0;
rate=0;
}
Bank(String n,String a,String t,double m,double j){
name=n;
Accountno=a;
type=t;
balance=m;
rate=j;
}
public void Deposit(double k) {
balance=balance+k;
}
public double withdraw(double m) {
if(balance > m) {
balance=balance-m;
return m;
}
else {
return 0;
}
}
public void Display() {
System.out.println("Name of the Account holder is "+name);
System.out.println("Account balance is "+Accountno);
System.out.println(" Type of the Account is "+type);
System.out.println(" Your balance is "+balance);
System.out.println("Rate of intrest is "+rate);
}
public static void main(String[] args) {
System.out.println("Invoking Default constructor");
Bank s=new Bank();
s.Display();
System.out.println("Invoking Parametrized constructor");
Bank s1=new Bank("Arpit","234567584","Savings",900000000,12);
s1.Display();
}
}