Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Modify the Account class to provide a service that allows funds to be transferred from one account to another. Note that a transfer can be
Modify the Account class to provide a service that allows funds to be transferred from one account to another. Note that a transfer can be thought of as withdrawing money from one account and depositing to another (for full credit, have your transfer method invoke the withdraw and deposit methods appropriately). Modify the main method of the Transactions class to demonstrate this new service.
Here's a prototype / header for the new transfer method of the Account class:
public void transfer (Account acctToWithdrawFrom, double amountToTransfer, double fee)
// Note: The fee is charged to the account from which the amount is withdrawn.
Modify the Transactions class above so that the data for the accounts are read from an input file; each line of the input file should correspond to the data for a single account; include data for 3 accounts e.g.:
Ted Murphy,72354,102.56
Jane Smith,69713,40.00
Edward Demsey,93757,759.32
In the first line of this example, the account holder's name is "Ted Murphy", the account number is 72354 and the initial balance is 102.56. (You may refer to the example NameReader.java which reads from text file names.txt .) Insert the missing code in InputManager.java which has a method for you to call from your Transactions class to read one line from a text file (e.g. accounts.txt) and returns an Account with the data from that line. Call the method readOneAccountFrom each time you need to read one line of account data from the input file, e.g.:
// In main method of Transactions
Account acct1 = InputManager.readOneAccountFrom (inputSource); // inputSource is a Scanner object.
The Employee class has Javadoc style comments for the constructor and each method, but the body of each method and constructor is empty. Implement each method and constructor according to the documentation provided. (Do not modify the method headers.) Write test cases in the main method of Driver class TestEmployee.java and check that for each test case, the expected result matches the actual result. Considering that 0 is a boundary value for hours worked and hourly rate (see the documentation for the method valid), update the test method so that it includes test cases that invoke methods appropriately for the following employees:
an employee with hours worked
an employee with hours worked
an employee with hours worked 0
an employee with hours worked = 0, hourly rate
an employee with hours worked = 0, hourly rate = 0
an employee with hours worked = 0, hourly rate > 0
an employee with hours worked > 0, hourly rate
csc 171 The e CSecure https/ 1515ea2e9bJbdSco ADELPHI UNIVERSITY Mail- 1 of 1,871 WALEED AL SHAHRANI cwaleedalshhan@al adeliphi edu 12 20 PM (1 minute agol Starred Sent Mal Orahs (56) 1 Modily the Accosst class to provide a service that allows funds to be teansfened from one account to another Note that a anafer can be thought of as witsrewig monry from one accoust and deposting to another toe full caedit, have your transfer method uvoke the withdeaw and derposdt methods appropriately) Modify the main method of the Irazoactiona.class to demonstrate das new service Mone- Hese's a prototype /header for the new ana fr method of the Accover class public void ransfer(Accouns acctToWhdran From, double asovet To Transfer, double fee) WALEED+ Note: The fee is charged to the account from whoch the amoust is wilraws 2.Modify de Trataactiona clan abore sothe data for de accouts are sead iern an ipat file, each bne ofthe itput file should cannpond toht da for a sangle account, include dats for 3 accounts e g 2354,182.5 ane Smith,6971348.00 Eduard Dencey93S7,9.2 la the first line of this example, the account holder's name is "Ted Muephy", the accoust number is 72354 and the inaihal balance is 102 56 (You may refer to the ample Sada which reads from text fileames.tst) Isset the ussing code in InpatMaragejaa whck has a method for you to call Som your Trazaactions class to read one lune from a test Eile (e g accontst) and reouns an Accouer with the data froes that ne Call the sethed readseAccountFrom each tim, you need to read one lir ofaccoutr data fem t tru file, eg account accti - nputrenager.readneccountro (Lnputsource)s sngutsource is Scanner abect. The Emplaser.class has Javadoc style commests for the constructor and each method, bat the body of each method and coestructor in empty Implemer each method and constructor accordng to the decumetation pron ided. (Do not modify the rethod headers)Wes cases n the main method of Daiver class IestEa and check that for each test case, the espected revalt csatches the actual pesult Considening thar O is a boundary value for hours woked and hourly rate (see the documentanoon for h, nedad ta ), updane the sest method so tha it meludes test cases that mok" tarthods appropritrdy for , illoning an emmplayee wh hours worked 0 bourly rane ani ttiployee with houn worked 0, lourly tant > 0 employee tsith houn worked-0, hurts rate o as employee sxth hours worked 0, borbrane csc 171 The e CSecure https/ 1515ea2e9bJbdSco ADELPHI UNIVERSITY Mail- 1 of 1,871 WALEED AL SHAHRANI cwaleedalshhan@al adeliphi edu 12 20 PM (1 minute agol Starred Sent Mal Orahs (56) 1 Modily the Accosst class to provide a service that allows funds to be teansfened from one account to another Note that a anafer can be thought of as witsrewig monry from one accoust and deposting to another toe full caedit, have your transfer method uvoke the withdeaw and derposdt methods appropriately) Modify the main method of the Irazoactiona.class to demonstrate das new service Mone- Hese's a prototype /header for the new ana fr method of the Accover class public void ransfer(Accouns acctToWhdran From, double asovet To Transfer, double fee) WALEED+ Note: The fee is charged to the account from whoch the amoust is wilraws 2.Modify de Trataactiona clan abore sothe data for de accouts are sead iern an ipat file, each bne ofthe itput file should cannpond toht da for a sangle account, include dats for 3 accounts e g 2354,182.5 ane Smith,6971348.00 Eduard Dencey93S7,9.2 la the first line of this example, the account holder's name is "Ted Muephy", the accoust number is 72354 and the inaihal balance is 102 56 (You may refer to the ample Sada which reads from text fileames.tst) Isset the ussing code in InpatMaragejaa whck has a method for you to call Som your Trazaactions class to read one lune from a test Eile (e g accontst) and reouns an Accouer with the data froes that ne Call the sethed readseAccountFrom each tim, you need to read one lir ofaccoutr data fem t tru file, eg account accti - nputrenager.readneccountro (Lnputsource)s sngutsource is Scanner abect. The Emplaser.class has Javadoc style commests for the constructor and each method, bat the body of each method and coestructor in empty Implemer each method and constructor accordng to the decumetation pron ided. (Do not modify the rethod headers)Wes cases n the main method of Daiver class IestEa and check that for each test case, the espected revalt csatches the actual pesult Considening thar O is a boundary value for hours woked and hourly rate (see the documentanoon for h, nedad ta ), updane the sest method so tha it meludes test cases that mok" tarthods appropritrdy for , illoning an emmplayee wh hours worked 0 bourly rane ani ttiployee with houn worked 0, lourly tant > 0 employee tsith houn worked-0, hurts rate o as employee sxth hours worked 0, borbrane an employee with hours worked > 0, hourly rate = 0
an employee with hours worked > 0, hourly rate > 0
Test cases count for 25% of the grade. Readability counts for 30%. Correctness counts for 45%. Follow the programming conventions/guidelines we discussed.
Hand in a printout of your programs and outputs. For part 2, also include your text file. The assignment may be done individually or in pairs (group of 2, following the principles of pair programming as discussed in class). If you work with someone else, hand in ONE copy with both names on it.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started