Skip to content

Commit 6763ff3

Browse files
committed
Modified and BankAccount Package.
1 parent 0660736 commit 6763ff3

File tree

2 files changed

+29
-30
lines changed

2 files changed

+29
-30
lines changed

Problems/src/Bank_Account/BankAccount.java

Lines changed: 25 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,56 +5,58 @@
55
* Filename: BankAccount
66
* Created By: Kimberly Henry
77
* On: 16-Jun-2014 At: 11:03 PM
8-
* <p/>
8+
*
99
* Create a class named BankAccount with fields that hold an account number, the owner’s name, and the account
1010
* 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.
1213
* Include a static method named explainAccountPolicy() that explains that the $4 service fee will be deducted
1314
* each month. Save the class as BankAccount.java.
1415
*/
1516
public class BankAccount
1617
{
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;
2021
public BankAccount()
2122
{
22-
accountNumber = 999999999;
23-
fullName = " ";
23+
accountNumber = 0;
24+
accountOwner = " ";
2425
accountBalance = 0;
2526
}
26-
public void setAccountNumber(int accountNumber)
27+
public void setAccountNumber(int acct)
2728
{
28-
accountNumber = accountNumber;
29+
accountNumber = acct;
2930
}
30-
public void setFullName(String fullName)
31+
public int getAccountNumber()
3132
{
32-
fullName = fullName;
33+
return accountNumber;
3334
}
34-
public void setAccountBalance(double accountBalance)
35+
public void setAccountOwner(String owner)
3536
{
36-
accountBalance = accountBalance;
37+
accountOwner = owner;
3738
}
38-
public int getAccountNumber()
39+
public String getAccountOwner()
3940
{
40-
return accountNumber;
41+
return accountOwner;
4142
}
42-
double getAccountBalance()
43+
public void setAccountBalance(double balance)
4344
{
44-
return accountBalance;
45+
accountBalance = balance;
4546
}
46-
public String getFullName()
47+
public double getAccountBalance()
4748
{
48-
return fullName;
49+
return accountBalance;
4950
}
50-
public void deductMonthlyFee()
51+
public double deductMonthlyFee()
5152
{
5253
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;
5556
}
5657
public void explainAccountPolicy()
5758
{
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());
5961
}
6062
}

Problems/src/Bank_Account/TestBankAccount.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Filename: TestBankAccount
77
* Created By: Kimberly Henry
88
* On: 16-Jun-2014 At: 11:04 PM
9-
* <p/>
9+
*
1010
* Create a class named TestBankAccount whose main() method declares four BankAccount objects. Call a getData()
1111
* method three times. Within the method, prompt a user for values for each field for a BankAccount, and return a
1212
* BankAccount object to the main() method where it is assigned to one of main()’s BankAccount objects. Do not
@@ -22,15 +22,12 @@ public static void main(String[] args)
2222
BankAccount test001 = new BankAccount();
2323
BankAccount test002 = new BankAccount();
2424
BankAccount test003 = new BankAccount();
25+
BankAccount test004 = new BankAccount();
2526
}
2627
public void getData()
2728
{
2829
Scanner enter = new Scanner(System.in);
29-
System.out.println("Enter Bank Account Number: ");
30-
// fixme BankAccount.se = enter.nextInt();
31-
System.out.println("Enter your full name: ");
32-
enter.nextLine();
33-
System.out.println("Enter account balance: ");
34-
enter.nextDouble();
30+
System.out.print("Enter account number");
31+
BankAccount.setAccountNumber(enter.nextInt());
3532
}
3633
}

0 commit comments

Comments
 (0)