-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBank.java
More file actions
75 lines (53 loc) · 1.38 KB
/
Copy pathBank.java
File metadata and controls
75 lines (53 loc) · 1.38 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
public class Bank {
public static void main(String args[])
{
BankAccount baObj1 = new BankAccount();
BankAccount baObj2 = new BankAccount();
baObj1.setbankAccount(1001, "Vedangi", 75000);
baObj2.setbankAccount(1002, "Shital", 75300);
baObj1.printBankAccount();
baObj2.printBankAccount();
baObj1.withraw(6000);
baObj2.deposit(6000);
baObj1.printBankAccount();
baObj2.printBankAccount();
}
}
class BankAccount
{
int accNo;
String accHolderName;
double balance;
void setbankAccount(int x, String y, float z)
{
accNo = x;
accHolderName = y;
balance =z;
}
double calculateSimpleInterest(int rateOfInterest, int period)
{
double simpleInterest = (balance*rateOfInterest*period)/100.0f;
return simpleInterest;
}
void withraw(double amountToWithdraw)
{
System.out.println("Windraw "+amountToWithdraw);
balance = balance - amountToWithdraw;
}
void deposit(double amountToDeposit)
{
System.out.println("Deposit "+amountToDeposit);
balance = balance + amountToDeposit;
}
double getBalance()
{
return balance;
}
void printBankAccount()
{
System.out.println("Account No: "+accNo);
System.out.println("Account holder name: "+accHolderName);
System.out.println("Balance : "+balance);
System.out.println("----------------------------");
}
}