- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBank.java
More file actions
Latest commit
44 lines (35 loc) · 883 Bytes
/
Copy pathBank.java
File metadata and controls
44 lines (35 loc) · 883 Bytes
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
packageClassAndObjects;
classBankAccount {
intaccountNum = 0;
floataccountBalance = 0;
publicBankAccount() {
}
publicBankAccount(intaccountNumber, floatbalance) {
accountNum = accountNumber;
accountBalance = balance;
}
voidsetAccountNumber(intnum) {
accountNum = num;
}
voidwithdraw(floatamount) {
accountBalance = accountBalance - amount;
}
voiddeposit(floatamount) {
accountBalance = accountBalance + amount;
}
voidstatus(){
System.out.println("Account Number: "+accountNum);
System.out.println("Account Balance: "+accountBalance);
}
}
publicclassBank {
publicstaticvoidmain(String[] arg) {
BankAccountaccount1 = newBankAccount();
account1.setAccountNumber(456);
account1.deposit(1000);
account1.status();
BankAccountaccount2 = newBankAccount(142, 2000);
account2.withdraw(500);
account2.status();
}
}