CSCUMPS 17 December 2020 1.The class and state machine diagrams below describe (simplified) CashISA objects. These are t
Posted: Fri May 20, 2022 12:46 pm
CSCUMPS 17 December 2020
1.The class and state machine diagrams below describe
(simplified) CashISA objects. These are tax-free savings accounts
which cap the deposits at £20,000 per tax year. CashISAs have
attributes for the current balance, the amount of money deposited
during the current tax year, and the annual interest rate (also
known as APR). CashISAs offer bank customers an operation to
deposit money. CashISAs offer the bank operations to start a new
tax year, and to end the tax year and credit the earned interest to
the account. The state machine diagram models an account with an
annual interest rate of 1.9%.
a)Write an outline Java class declaration for the CashISA class,
based on the information in the class diagram. Leave the method
bodies empty.
b)Complete the implementation of the CashISA class by
translating the state machine diagram into Java code. This
translation requires no knowledge of actual CashISA savings
accounts. Syntactic correctness of your Java code is not important,
but your code must be functionally correct, that is, it
should implement exactly the functionality specified by the state
machine diagram.
Visual Paradigm Online Diagrams Express CashISA -bal: double -dep: double -apr: double +CashISAO +deposit(amt: double): void +startTax Year(): void +endTax Year(): void Paradigm Online Diagrams Express Edition
Visual Paradigm Online Diagrams Express Edition deposit(amt) (dep + amt <20000] / bal = bal + amt; dep = dep+amt deposit(amt) (dep + amt == 20000] / bal = bal + amt; dep = dep + amt Allow Deposits Deny Deposits endTaxYear() end Tax Year() /bal = 0; dep = 0; apr = 1.9 Earn Interest entry / bal = bal + bal · apr / 100 startTax Year()/ dep = 0 Visual Paradigm Online Diagrams Express Edition
1.The class and state machine diagrams below describe
(simplified) CashISA objects. These are tax-free savings accounts
which cap the deposits at £20,000 per tax year. CashISAs have
attributes for the current balance, the amount of money deposited
during the current tax year, and the annual interest rate (also
known as APR). CashISAs offer bank customers an operation to
deposit money. CashISAs offer the bank operations to start a new
tax year, and to end the tax year and credit the earned interest to
the account. The state machine diagram models an account with an
annual interest rate of 1.9%.
a)Write an outline Java class declaration for the CashISA class,
based on the information in the class diagram. Leave the method
bodies empty.
b)Complete the implementation of the CashISA class by
translating the state machine diagram into Java code. This
translation requires no knowledge of actual CashISA savings
accounts. Syntactic correctness of your Java code is not important,
but your code must be functionally correct, that is, it
should implement exactly the functionality specified by the state
machine diagram.
Visual Paradigm Online Diagrams Express CashISA -bal: double -dep: double -apr: double +CashISAO +deposit(amt: double): void +startTax Year(): void +endTax Year(): void Paradigm Online Diagrams Express Edition
Visual Paradigm Online Diagrams Express Edition deposit(amt) (dep + amt <20000] / bal = bal + amt; dep = dep+amt deposit(amt) (dep + amt == 20000] / bal = bal + amt; dep = dep + amt Allow Deposits Deny Deposits endTaxYear() end Tax Year() /bal = 0; dep = 0; apr = 1.9 Earn Interest entry / bal = bal + bal · apr / 100 startTax Year()/ dep = 0 Visual Paradigm Online Diagrams Express Edition