UML:
Class 1 :
Account Test
****************************************************
* Name: YOUR NAME HERE
* Date: ++++++++++
* Purpose:
* Input: {Checking inital deposits and (deposit/withdraw)}{ Savings inital deposits and (deposit/withdraw)}
* Processing: running totals, counters, multiplication, division
* Output: What results will be displayed to the user
* -------------Monthly Transactions------------
Deposit transaction Number: 1 Amount 10.0
Withdrawl Transactoin Number: 1 Amount 23.0
Withdrawl Transactoin Number: 2 Amount 434.05
Deposit transaction Number: 2 Amount 650.0
Withdrawl Transactoin Number: 3 Amount 43.0
Withdrawl Transactoin Number: 4 Amount 80.0
Deposit transaction Number: 3 Amount 5.0
Withdrawl Transactoin Number: 5 Amount 20.0
End of the month:
-------------------
-------------------
Savings balance = $953.08
Checking balance = $164.95
****************************************************************/
package lastlab;
import java.text.*;
public class AccountTest
{
public static void main(String[] args)
{
System.out.println("-------------Monthly Transactions------------");
//change values here
SavingsAccount Savings =
new SavingsAccount(100);
CheckingAccount Checking =
new CheckingAccount(100);
Savings.deposit(434);
Savings.deposit(100);
Savings.transfer(Checking, 10);
Checking.withdraw(23);
Checking.withdraw(434.05);
Checking.deposit(650);
Savings.deposit(434.05);
Checking.withdraw(43);
Checking.withdraw(80);
Savings.transfer(Checking, 5);
Checking.withdraw(20);
//end of month reconsiling
Savings.addInterest();
Checking.deductFees();
DecimalFormat df = new DecimalFormat("#.##");
//Display set up
System.out.println("");
System.out.println("End of the month:");
System.out.println("-------------------");
System.out.println("-------------------");
System.out.println("");
System.out.println("Savings balance = $" +df.format(Savings.getBalance()));
System.out.println("Checking balance = $" +df.format(Checking.getBalance()));
}
}
Class 2:
Bank Account
package lastlab;
public class BankAccount
{
public BankAccount()
{
balance = 0;
}
public BankAccount(double initialBalance)
{
balance = initialBalance;
}
public void deposit(double amount)
{
balance = balance + amount;
}
public void withdraw(double amount)
{
balance = balance - amount;
}
public double getBalance()
{
return balance;
}
public void transfer(BankAccount other, double amount)
{
withdraw(amount);
other.deposit(amount);
}
protected double balance;
}
Class 3:
Checking Account
package lastlab;
public class CheckingAccount extends BankAccount
{
public CheckingAccount(int initialBalance)
{
super(initialBalance);
DtransactionCount = 0;
WtransactionCount = 0;
}
public void deposit(double amount)
{
DtransactionCount++;
System.out.println("Deposit transaction Number: " +DtransactionCount +(" Amount " ) + amount );
super.deposit(amount);
}
public void withdraw(double amount)
{
WtransactionCount++;
System.out.println("Withdrawl Transactoin Number: " + WtransactionCount+ (" Amount ") + amount );
super.withdraw(amount);
}
public void transCount(double amount)
{
TtransactionCount=DtransactionCount+WtransactionCount;
System.out.println("Total Transactions: " + TtransactionCount);
}
public void deductFees()
{
if
(TtransactionCount <= 4)
{
double fees1 = (0);
super.withdraw(fees1);
}
else
{
double fees1 = (25);
super.withdraw(fees1);
}
}
private int DtransactionCount;
private int WtransactionCount;
private int TtransactionCount;
}
Class 4:
Savings Account
package lastlab;
public class SavingsAccount extends BankAccount
{
public SavingsAccount(double rate)
{
interestRate = .01;
}
public void addInterest()
{
double interest = getBalance()*interestRate/365;
deposit(interest);
}
private double interestRate;
}
Class 1 :
Account Test
****************************************************
* Name: YOUR NAME HERE
* Date: ++++++++++
* Purpose:
* Input: {Checking inital deposits and (deposit/withdraw)}{ Savings inital deposits and (deposit/withdraw)}
* Processing: running totals, counters, multiplication, division
* Output: What results will be displayed to the user
* -------------Monthly Transactions------------
Deposit transaction Number: 1 Amount 10.0
Withdrawl Transactoin Number: 1 Amount 23.0
Withdrawl Transactoin Number: 2 Amount 434.05
Deposit transaction Number: 2 Amount 650.0
Withdrawl Transactoin Number: 3 Amount 43.0
Withdrawl Transactoin Number: 4 Amount 80.0
Deposit transaction Number: 3 Amount 5.0
Withdrawl Transactoin Number: 5 Amount 20.0
End of the month:
-------------------
-------------------
Savings balance = $953.08
Checking balance = $164.95
****************************************************************/
package lastlab;
import java.text.*;
public class AccountTest
{
public static void main(String[] args)
{
System.out.println("-------------Monthly Transactions------------");
//change values here
SavingsAccount Savings =
new SavingsAccount(100);
CheckingAccount Checking =
new CheckingAccount(100);
Savings.deposit(434);
Savings.deposit(100);
Savings.transfer(Checking, 10);
Checking.withdraw(23);
Checking.withdraw(434.05);
Checking.deposit(650);
Savings.deposit(434.05);
Checking.withdraw(43);
Checking.withdraw(80);
Savings.transfer(Checking, 5);
Checking.withdraw(20);
//end of month reconsiling
Savings.addInterest();
Checking.deductFees();
DecimalFormat df = new DecimalFormat("#.##");
//Display set up
System.out.println("");
System.out.println("End of the month:");
System.out.println("-------------------");
System.out.println("-------------------");
System.out.println("");
System.out.println("Savings balance = $" +df.format(Savings.getBalance()));
System.out.println("Checking balance = $" +df.format(Checking.getBalance()));
}
}
Class 2:
Bank Account
package lastlab;
public class BankAccount
{
public BankAccount()
{
balance = 0;
}
public BankAccount(double initialBalance)
{
balance = initialBalance;
}
public void deposit(double amount)
{
balance = balance + amount;
}
public void withdraw(double amount)
{
balance = balance - amount;
}
public double getBalance()
{
return balance;
}
public void transfer(BankAccount other, double amount)
{
withdraw(amount);
other.deposit(amount);
}
protected double balance;
}
Class 3:
Checking Account
package lastlab;
public class CheckingAccount extends BankAccount
{
public CheckingAccount(int initialBalance)
{
super(initialBalance);
DtransactionCount = 0;
WtransactionCount = 0;
}
public void deposit(double amount)
{
DtransactionCount++;
System.out.println("Deposit transaction Number: " +DtransactionCount +(" Amount " ) + amount );
super.deposit(amount);
}
public void withdraw(double amount)
{
WtransactionCount++;
System.out.println("Withdrawl Transactoin Number: " + WtransactionCount+ (" Amount ") + amount );
super.withdraw(amount);
}
public void transCount(double amount)
{
TtransactionCount=DtransactionCount+WtransactionCount;
System.out.println("Total Transactions: " + TtransactionCount);
}
public void deductFees()
{
if
(TtransactionCount <= 4)
{
double fees1 = (0);
super.withdraw(fees1);
}
else
{
double fees1 = (25);
super.withdraw(fees1);
}
}
private int DtransactionCount;
private int WtransactionCount;
private int TtransactionCount;
}
Class 4:
Savings Account
package lastlab;
public class SavingsAccount extends BankAccount
{
public SavingsAccount(double rate)
{
interestRate = .01;
}
public void addInterest()
{
double interest = getBalance()*interestRate/365;
deposit(interest);
}
private double interestRate;
}
No comments:
Post a Comment