|
5 | 5 | * Filename: BankAccount
|
6 | 6 | * Created By: Kimberly Henry
|
7 | 7 | * On: 16-Jun-2014 At: 11:03 PM
|
8 |
| - * <p/> |
| 8 | + * |
9 | 9 | * Create a class named BankAccount with fields that hold an account number, the owner’s name, and the account
|
10 | 10 | * balance. Include a constructor that initializes each field to appropriate default values. Also include methods to
|
11 |
| - * get and set each of the fields. Include a method named deductMonthlyFee() that reduces the balance by $4.00. |
| 11 | + * get and set each of the fields. |
| 12 | + * Include a method named deductMonthlyFee() that reduces the balance by $4.00. |
12 | 13 | * Include a static method named explainAccountPolicy() that explains that the $4 service fee will be deducted
|
13 | 14 | * each month. Save the class as BankAccount.java.
|
14 | 15 | */
|
15 | 16 | public class BankAccount
|
16 | 17 | {
|
17 |
| - private final int accountNumber; |
18 |
| - private final String fullName; |
19 |
| - private final double accountBalance; |
| 18 | + private int accountNumber; |
| 19 | + private String accountOwner; |
| 20 | + private double accountBalance; |
20 | 21 | public BankAccount()
|
21 | 22 | {
|
22 |
| - accountNumber = 999999999; |
23 |
| - fullName = " "; |
| 23 | + accountNumber = 0; |
| 24 | + accountOwner = " "; |
24 | 25 | accountBalance = 0;
|
25 | 26 | }
|
26 |
| - public void setAccountNumber(int accountNumber) |
| 27 | + public void setAccountNumber(int acct) |
27 | 28 | {
|
28 |
| - accountNumber = accountNumber; |
| 29 | + accountNumber = acct; |
29 | 30 | }
|
30 |
| - public void setFullName(String fullName) |
| 31 | + public int getAccountNumber() |
31 | 32 | {
|
32 |
| - fullName = fullName; |
| 33 | + return accountNumber; |
33 | 34 | }
|
34 |
| - public void setAccountBalance(double accountBalance) |
| 35 | + public void setAccountOwner(String owner) |
35 | 36 | {
|
36 |
| - accountBalance = accountBalance; |
| 37 | + accountOwner = owner; |
37 | 38 | }
|
38 |
| - public int getAccountNumber() |
| 39 | + public String getAccountOwner() |
39 | 40 | {
|
40 |
| - return accountNumber; |
| 41 | + return accountOwner; |
41 | 42 | }
|
42 |
| - double getAccountBalance() |
| 43 | + public void setAccountBalance(double balance) |
43 | 44 | {
|
44 |
| - return accountBalance; |
| 45 | + accountBalance = balance; |
45 | 46 | }
|
46 |
| - public String getFullName() |
| 47 | + public double getAccountBalance() |
47 | 48 | {
|
48 |
| - return fullName; |
| 49 | + return accountBalance; |
49 | 50 | }
|
50 |
| - public void deductMonthlyFee() |
| 51 | + public double deductMonthlyFee() |
51 | 52 | {
|
52 | 53 | double monthlyFee = 4.00;
|
53 |
| - double newBalance = getAccountBalance() - monthlyFee; |
54 |
| - System.out.println("Your balance after the monthly fees are " + newBalance); |
| 54 | + double newAccountBalance = accountBalance - monthlyFee; |
| 55 | + return newAccountBalance; |
55 | 56 | }
|
56 | 57 | public void explainAccountPolicy()
|
57 | 58 | {
|
58 |
| - System.out.println("The $4 service fee will be deducted each month."); |
| 59 | + System.out.println("The $4 service fee will be deducted on a monthly basis."); |
| 60 | + System.out.println("Your new account balance is " + deductMonthlyFee()); |
59 | 61 | }
|
60 | 62 | }
|
0 commit comments