© Anthony W. Smith, 2016CSCI 114 Programming Fundamentals IILab 5 InheritanceLab 5 InheritancePurposePurpose is to follow utilizing common inheritance.The Checking superclassFirst design, code and check a category known as Checking. This shall be your superclass.Use precisely and solely these occasion variables:personal String accountIDprivate int balanceprivate int numDepositsprivate int numWithdrawalsprivate double annualRateprivate int serviceCharge-an figuring out account quantity e.g. “123”-balance of the account in pennies, to keep away from floatingpoint round-off errors e.g. 100 means $1.00-number of deposits made this month-number of withdrawals made this month-annual rate of interest e.g. zero.15 means 15% perannum-maintain the complete month-to-month service costs incurredhere, in penniesChecking could have the following strategies. Be careful to implement the steps of eachmethod in precisely the order given under:constructor-has parameters for the account ID, beginning steadiness (in dollars) and annual curiosity rate-must initialize all occasion variables-use the following to convert the greenback beginning steadiness parameter bal to cents, avoidinground-off error:steadiness = (int) Math.spherical(bal * 100.zero);acceptable get and set methods-you have to resolve throughout design what get and set strategies are requireddeposit()-has a parameter for the deposit quantity in dollars-make the needed conversion then add the quantity to the balance-increment the quantity of deposits-add a deposit payment of 10 cents (in pennies) to the month-to-month service charge1© Anthony W. Smith, 2016CSCI 114 Programming Fundamentals IILab 5 Inheritance-note that the deposit payment is NOT deducted from steadiness at the time of the deposittransaction-(use static closing constants for all the payment quantities)withdraw()-has a parameter for the withdrawal quantity in dollars-make the needed conversion then subtract the quantity from the balance-increment the quantity of withdrawals-add a withdrawal payment (in pennies) to the month-to-month service cost:-the first 2 withdrawals value 25 cents each-withdrawals after the first 2 value 75 cents eachdepositInterest()-update the steadiness by calculating the month-to-month curiosity earned on the account, then addthis curiosity to the steadiness. In pseudocode:month-to-month rate of interest = annual rate of interest / 12.0monthly curiosity = steadiness * month-to-month curiosity ratebalance = steadiness + month-to-month interest-(use Math.spherical() the place needed to forestall rounding errors)printMonthEnd()-run at the finish of the month to first add curiosity, then deduct month-to-month service costs,than summarize the account. In pseudocode (implement these actions in precisely thisorder):name the depositInterest() methodadd a month-to-month payment of $1.00 to the month-to-month service chargedecrease the steadiness by the complete month-to-month service chargeoutput the account ID, ensuing steadiness, quantity of deposits and withdrawals and themonthly service cost (use printf() to output financial quantities in dollars, with 2decimal locations)set the quantity of deposits and withdrawals and month-to-month service cost to zero-an instance of the printMonthEnd() output format:Account ID 123Stability is: $751.881 deposits, three withdrawalsMonthly service cost was: $2.352© Anthony W. Smith, 2016CSCI 114 Programming Fundamentals IILab 5 InheritancetoString()-return a String that represents the Checking object, should be in standardized formattinge.g.Checking[accountID=123, balance=74800, numDeposits=1, numWithdrawals=3,annualRate=0.1, serviceCharge=135]The MoneyMarket subclassNext design, code and check a MoneyMarket subclass that inherits from Checking.MoneyMarket occasion variable:activea boolean variable that maintains the standing of the account. Standing isdefined as energetic if the steadiness is larger than a minimal steadiness of$500.00, in any other case will not be energetic. Account standing should be updatedevery time the account steadiness is modified. Withdrawals are notallowed if the account will not be energetic, till deposits make the accountactive againMoneyMarket could have the following strategies Be careful to implement the steps ofeach methodology in precisely the order given under:constructor-has parameters for account ID, the beginning steadiness (in dollars) and annual curiosity rate-use the superclass constructor to set these-then set whether or not the account is energetic or not activewithdraw()-output a message in the following format if the account will not be energetic, and carried out:MoneyMarket 456: Withdrawal not allowed-otherwise name Checking withdraw() (use tremendous to do that), then should replace the statusof the accountdeposit()-call Checking deposit() (use tremendous to do that), then should replace the standing of theaccountprintMonthEnd()-run at the finish of the month to add curiosity, deduct month-to-month service costs andsummarize the account. In pseudocode (implement these actions in precisely this order):3© Anthony W. Smith, 2016CSCI 114 Programming Fundamentals IILab 5 Inheritanceadd a minimal steadiness payment of $5.00 to the month-to-month service payment if the account is notactivecall Checking monthEnd() (use tremendous to do that)replace standing of the accountoutput the standing of the account e.g."Cash market account is: energetic" or"Cash market account is: inactive"-an instance of the printMonthEnd() output format for the MoneyMarket class:Account ID 456Stability is: $296.151 deposits, 1 withdrawalsMonthly service cost was: $6.35Cash market account is: inactivetoString()-return a String that represents the MoneyMarket object, should be in standardizedformatting e.g.MoneyMarket[accountID=456, balance=30000, numDeposits=1,numWithdrawals=1, annualRate=0.1, serviceCharge=35][active=false]The Tester classThe Tester class assessments your new Checking and MoneyMarket lessons. Supply code forTester is given under, and will be downloaded from Blackboard, Course Paperwork,Week 12, Instance packages.import java.util.ArrayList;/*** Driver for Lab 5 Inheritance** @creator Anthony W. Smith* @model 5/31/2028*/public class Testerpublic static void major(String arg)// create some accounts// $100.00, 10.zero% annual interestChecking examine = new Checking("123", 100.zero, zero.1);// $1000.00, 10.zero% annual interestMoneyMarket cash = new MoneyMarket("456", 1000.zero, zero.1);4© Anthony W. Smith, 2016CSCI 114 Programming Fundamentals IILab 5 InheritanceArrayList<Checking> accounts = new ArrayList<>();accounts.add(examine);accounts.add(cash);// do some transactionsSystem.out.println("Transactions");// on Checking objectcheck.deposit(750.zero);examine.withdraw(12.zero);examine.withdraw(34.zero);examine.withdraw(56.zero);// on MoneyMarket objectmoney.withdraw(750.zero);cash.withdraw(100.zero);cash.deposit(50.zero);// print accountsSystem.out.println("
Print accounts");for (Checking c : accounts)System.out.println(c.toString());// print month finish reportSystem.out.println("
Month finish report");for (Checking c : accounts) Hintsfirst, take a calculator and work rigorously via Tester line by line, writing downon a chunk of paper the values of the occasion variables that must be produced…this makes certain you perceive what each methodology does, and offers you the expectedoutput you want to check your programnow design your new Checking and MoneyMarket lessons on a chunk of paperuse inheritance – a MoneyMarket account is-a Checking account, with an accountstatus addeddesign algorithms, take into consideration parameters and return valuesthen use BlueJ as typical to code and check each methodology in flip. Remark out in Testerthe strategies you haven’t but implemented5© Anthony W. Smith, 2016CSCI 114 Programming Fundamentals IILab 5 InheritanceRequiredTester in your closing submission should not be modified in any wayevery methodology should have a transparent, significant Javadoc commenteach toString() is required to use standardized formattingautomatically and routinely use all the different parts of simplicity and readability, aslisted in Blackboard, Course Info, “How labs are graded”when you’ve completely examined your program and are sure it’s appropriate, save youroutput into the output.txt fileLab 5 submissiondeadline for this lab is three weeks, by finish of Sunday 5/1zip your BlueJ mission plus output.txt output file and electronic mail to me atawsmith@palomar.eduyou will lose factors if you don’t embrace a file named output.txt containing theoutput of your programyour electronic mail Topic line should say ‘CSCI 114 Lab 5’ adopted by your full identify, sothat it filters to the appropriate electronic mail folder for gradingyou will lose factors should you format your electronic mail Topic incorrectlye.g. my electronic mail Topic can be:CSCI 114 Lab 5 Anthony W. Smiththis is a graded lab, so a reminder that you could be not copy code from different peoplereminder that late labs shall be penalized 2 factors per week or half of week late6

Published by
Essays
View all posts