Skip to content

Commit 98d994c

Browse files
committed
Modified and BankAccount and moved Package.
1 parent 878c76b commit 98d994c

File tree

2 files changed

+36
-12
lines changed

2 files changed

+36
-12
lines changed

Problems/src/Bank_Account/BankAccount.java renamed to Chapter03/src/Bank_Account/BankAccount.java

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
package Bank_Account;
2+
import java.util.Scanner;
23
/**
34
* Project: Java Programming
45
* Package: Bank_Account
@@ -24,25 +25,26 @@ public BankAccount()
2425
accountOwner = " ";
2526
accountBalance = 0;
2627
}
27-
public void setAccountNumber(int acct)
28+
public void setAccountNumber()
2829
{
29-
accountNumber = acct;
30+
accountNumber = accountNumber;
3031
}
3132
public int getAccountNumber()
3233
{
3334
return accountNumber;
3435
}
35-
public void setAccountOwner(String owner)
36+
public void setAccountOwner()
3637
{
37-
accountOwner = owner;
38+
accountOwner = accountOwner;
3839
}
40+
3941
public String getAccountOwner()
4042
{
4143
return accountOwner;
4244
}
43-
public void setAccountBalance(double balance)
45+
public void setAccountBalance()
4446
{
45-
accountBalance = balance;
47+
accountBalance = accountBalance;
4648
}
4749
public double getAccountBalance()
4850
{
@@ -51,12 +53,30 @@ public double getAccountBalance()
5153
public double deductMonthlyFee()
5254
{
5355
double monthlyFee = 4.00;
54-
double newAccountBalance = accountBalance - monthlyFee;
55-
return newAccountBalance;
56+
return accountBalance - monthlyFee;
5657
}
5758
public void explainAccountPolicy()
5859
{
5960
System.out.println("The $4 service fee will be deducted on a monthly basis.");
6061
System.out.println("Your new account balance is " + deductMonthlyFee());
6162
}
63+
public void getData()
64+
{
65+
Scanner enter = new Scanner(System.in);
66+
System.out.print("Enter account number: ");
67+
accountNumber = enter.nextInt();
68+
System.out.print("Enter account balance: ");
69+
accountBalance = enter.nextDouble();
70+
enter.nextLine();
71+
System.out.print("Enter account owner: ");
72+
accountOwner = enter.nextLine();
73+
}
74+
public void showData()
75+
{
76+
System.out.println("Bank Account Number: " + getAccountNumber());
77+
System.out.println("Account Owner: " + getAccountOwner());
78+
System.out.println("Account Balance: " + getAccountBalance());
79+
explainAccountPolicy();
80+
}
81+
6282
}

Problems/src/Bank_Account/TestBankAccount.java renamed to Chapter03/src/Bank_Account/TestBankAccount.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
package Bank_Account;
2-
import java.util.*;
32
/**
43
* Project: Java Programming
54
* Package: Bank_Account
@@ -25,8 +24,13 @@ public static void main(String[] args)
2524
BankAccount test002 = new BankAccount();
2625
BankAccount test003 = new BankAccount();
2726
BankAccount test004 = new BankAccount();
27+
test001.getData();
28+
test001.showData();
29+
test002.getData();
30+
test002.showData();
31+
test003.getData();
32+
test003.showData();
33+
test004.showData();
2834
}
29-
public void getData()
30-
{
31-
}
35+
3236
}

0 commit comments

Comments
 (0)