View the step-by-step solution to:


I really need some help figuring out this problem. I have provided everything to solve. This would be greatly appreciated!!



k**************k***+*#*******+*********+**W**+*********+*****+*****+****i***********w********$**********k*********f } I! end prepSecurityCollection Iii-iii:**+******i***i—ki*i+*t*+*****+***+i+**iii-ink*i’i'i'fiiii—‘l-fii5ii-i-i*ii—+i**i*+*******ili'i'idi*iiifi******i**k****fi*******i * Report Equity Positions
*‘ktt*i‘k‘ltt*iti*t‘l’i‘kt*iftttf‘k‘kkifi‘k‘ktfif‘l‘k‘kt*‘k‘kfk*i‘kttfiii‘l’kni-l-itki‘l‘kittiiftti‘k‘kitti’i‘ktiii-1kfittiiifiitikitittttiittif {i * Once both input files have been read, both collections built, and both sorted,
* Use a matching algorithm to report equity positions for all Customers
public static void reportEquityPositionst )
ft * Declare an object to use to move through the collection of Security objects * Using that object, pick up the 'next' Security object available, assign it the name ’equity'
* Retrieve the custflumber value from that object and store it in a variable named 'holquuity'
*1 (tests—wrttlwrrtiltit:tuttiterrificfitterirttw*Ittwcriticritufitttlurttiirrttucriticnttiwfittl‘witnwetttlwittlrntttfiitt
*rrtttitttiwirtiiflirtwrist*iittufitit—wurine*Itt**ttt**Irtuttttiiittnifirttientree*ttifiittifi*ttnwfiitttuittliitttwit ***"***"I**"*'* ADD THE FOLLOWING CODE =RBOVE= THE CALL TO findCustomer: t*-tttr*twt*rtttr* Declare an iterator for use with the Security collection t**twtr*ttt**tttr* Use that iterator to retrieve a Security object; name the object retrieved "equity”
nrrwwwrrtww*rwwtt* Retrieve the custnumber of the equity object; store it as "helquuity" *tttttt*ittxttite*tttitkit*ttti***i****tt***itti*kiitehit***iii*hiiittitii*tinwe*tiixtktii*itnttktttttkteektttxtk
ekittt**it**ttite*ttittkiit*tiittheta*ttta**hite*kit***it**iiiieitiaittine*tintettii*t*itttttntittet***te**ttt*tkif findCuetomer( helquuity }; I! Pass the cuetNumber value retrieved from the Security try
whilet true 3
while[ equity.get€uatNumberl }.matcheat holquuity 1 l {
fl Output a line describing thie Security System.aut.printf( "\ti-lfle i-Se carries a coat basis of $155%n“,
equity.getclaee[ ).getName( ),
equity.get3ymbol( l,
String.fcrmat( "5%,.2f", equity.caloCost( J I j: I! Have to the next Security
Jann'iftr a unnl1TiPqu#r=+'nr.nfi-v+f l u


Background We now have the beginnings of a functioning application. The next step is to prepare a process for
reporting the investments held by each of our customers. The backbone of the reporting logic has been provided to vou. You must furnish certain, specific
portions of the logic in order to complete the report processing code. Provided to you
The following have been provided to you: 0 These instructions
0 UML Class Diagrams {NOT E: These are unchanged from PAOB) 0 Serialized files and supporting executables [in a zipped folder):
0 Customer . ser and the Customer-.class file used to build it 0 Security . sec and the Security.class, MutualFund. class and Stock .class
files used to build it
o CustomerException .class and SecurityException.class
o CostBasis.class
- An Excel workbookshowing the data contained in the two serialized files.
0 The expected results from the completed Cu stomer‘AccountRepor't . java code
0 Customer‘AccountRepor‘t . java containing much of the needed logic and which you will
complete, compile, and debug as needed a A grading rubric for the assignment Deliverables Submit your completed Customer-Accountlteport . java, Customer-Custl'iumber. java, and
SecurityCustNunber. java source files as attachments to the assignment. You do not need to zip
the files. DO NOT submit class code [compiledlbuilt code], edit backups {.java'“ files), or anything other
than the lhminfllfl: Items listed above, In the format specified. Requirements Custom Comparators
You will need to write two custom comparator classes: 0 Produce a custom comparator class to sort Customer objects into ascending order based on
the custNumber instance variable. Name the custom comparator CustomerCustNumber. 0 Produce a custom comparator class to sort the Security objects into ascending order based
on the custlllumber‘ instance variable. Name the custom comparator Securitytustmmiber'.


“ ”murals. u 4.4.“: neckline“: “use: ”EMMA—Lu! System.out.printf[ "\tt—IOs t-Ss carries a cost basis of ilfistn",
eguity.getclass[ ).getName[ ),
equity.get5ymbol[ )r
String.fermat[ "$%,.2f", equity.ealcCest( ) ) };
fl Move to the next Security
equity = ); } I! end INNER while
I] This is just an indication that we're done with this Customer's Security objects 5): stem. out . print f t " =_=—=_==_=__________—=_==_=_=_==_=—=_==_=—___—__=_=__==_=__=_=_=%n 311" j ;
holquu it]? = equity . getCustNumbert J :
findCustomer( holquuity J; } If and OUTER while }
catch[ NoSuchElementhception endeColIection } {
* This Exception is EKPECTED to be thrown when we 'run out' of Security or Customer objects
System.out.printf( "%n%n\t\t\t ***** END OF EQUITY REPORT *****%n" J:
} fl end catch NoSuchElementException } If end reportsquitypoeitione [atkid:*i**********iki‘i‘ii‘irki'k'k‘kirifirii'iri‘fi‘wiic'kiakin?kid:*****\t**‘I-i#i‘i#i‘ahki‘#**i******i********\‘ri‘itii**********ik*i*i***k** * Find Customer
itittiti’itiikifiiitiiiitiiti‘ktitt‘kfiiititiitiiiiititiiti‘ti’itiikiitikiiiiititi‘ktifitifiiititiiititiitiiiitiiiitiitif ft
* Using the target custNumher passed into the method from the calling code...
* Search the sotred and sorted Customer objects for the one matching the provided target
* Assign the located Customer object to the reference found
* Using the Customer reference found, produce the report header
public static void findCustomert String findCust J
Customer target; l! 'template' for search process Customer found: If 'holding space' for the located Customer object * Set up for Customer search.
* The "important" piece is the oustNumher —b findCust_hll other information is essentially filler and
* will not be used in the search process.
target = new Customer{ findCust,


1tr2r2trxrrwrrrrrrrrrrrrrrr-rrrxrrrrwrwrwrwxxwxwxxv«wxx«x«xxxx«xXxxx«xxxwxx1xxx?!wtxx11rwtwtrrwrrrrrrrrrrrrrrr; {a * Deserialize all objects from serialized Customer file * As each object is deserialized (read), add it to the collection holding Customer objects
* Once all Customer objects have been stored in the collection, * Sort the collection in ascending order, based on custNumher value of each object. *f public static void prepCustomerCollectiont ]
throws classNotFoundException, IOExoeption /******+**i********i**fif**ii*****************************************i*******i*iiiii*ii*i+i***ii***************#k*
1tiitiiitiiiitiifiiiiiiiitititkiktiiitiitiiiititiiiitiiiiiiitititiiiiiiii1iiiiii1itittiiiiiitiitittitiititiiiittifi eteiatcerirceccccc
*ciiii+i+i*i*i**** EDD CODE TO: DESERILLIZE CUSTOMER OBJECTS ADD OBJECTS TO COLLECTION HANDLE NECESSARY EXCEPTIONS SORT COMPLETED COLLECTION INTO BSCENDING ORDER BY CuetNumber tititifiiiitttitttttttttttitittointinenoon*xntntnnnnnnnnnntnnono*n*nttit*1tititititititittitretittiettiititititttt aQ1*4Qw!wkw!wiw*e§i*e¥9wowie*ewflwww**ww***kw************w*******w*wwww**4*wwwaweweyaQ!Q4i+i¥£¥wtwewewiwrw9eieiepow] } if end prepCustomerCollection I*fi*1*1***+****i******l*§9**i*i9*D****R******R*R****************************Q*9**i*i*****1ifli+i*i¥i***********9* * Prepare the Security collection
iiiII!’1'QQI!IIII"Q!.!EEQQEQ*QWQQ(kitkitViki*‘k**************5!************9£*5!*I‘filfl'fl'fl*flifi’l‘ififi*l'fll"QQ!IIII’IIQIII!IEEQEQIIQ*/ ;*
* Deserialize all objects from serialized Security file
* As each object is deserialized (read), add it to the collection holding Security objects
* Once all Security objects have been stored in the collection,
* Sort the collection in ascending order, based on custNumher value of each object.
* I public static void prepSecurityCollectiont )
throws ClassHotFoundException, IOException f!it9&t!§r§ttttttttttewewtwtowkwknwe*w**wnwkw***********************wwww*4wwww!may9w!km’4§!§t§tttttittttttt*twtewwe
iiiii****i***iiiiiiiiii**+i**i*kik*i*******i*******$************i*i**i*i**i*+i*iiiii*iiiiiiii*********+***+i+**** twitttttrttttttiii
1t1f11*11frfifi*ti ADD CODE TO: DESERIALIZE SECURITY OBJECTS ADD OBJECTS TO COLLECTION HANDLE NECESSARY EXCEPTIONS SORT COMPLETED COLLECTION INTO ASCENDING ORDER BY cuEtNuthr ttiii******itititiiiiiiii*ittkt#tttittt*ttttititititititttitttttiitititiitiifitiiiittiiiiiiit*itititiiiiiifi*ittt
tt1Ittrttttttttttttttttttnttttttnknanntnt*x2*2****1*****n*2****n**k!inat*k!*1kit,*1*1I!trlrttttttttttttttwtttttenf } [I end prepSecurityCollection ffitt11**tteit’ttctctcwttewewtwtececenwa*w***************************fi******we*wfiweriflewe****ieitfittttfitcttttttwt



t * Process matchfmerge based on Customer.
* For each Customer: ' Output Customer information. 1 Output Security information * Output CostBasia for Security 1‘ if public static void processfleport[ )
throws Exception
try {
prepCustomerCollection( }; prepSecurityCollection[ ):
reportEquityPositions{ ]; }
catch[ Exception err )
System.err.printf( "serious error. Ending prooes. %e",
err.getClass( ).getName( } J:
err.print5tackTrace( J;
} } I! end method processRecords [o***Qoo***kto***Rr*****oo***aook**too**R*t***wkofi**R?!***Rfioo***io***profi***t¥***aiok**e*9***Qlo****¥ow***tflfiflw * Close the input files
public static void closaFiles{ J
throws IOException { I***************************i*****************************i**************************************i*******¥*********
**Qo***kto***koofi***oo***k*wk**too***&t****otfi**or!***fikoo***to***wooe***tt***aiok**eoo***ktoo**k¥ow***ofl**akook* *'*****"********* EDD CODE TO CLOSE INPUT FILES, INCLUDED NECESSARY EXCPETION HANDLING
**!***w*****kw*****+!fl**flfl¥fi********RQ*£****¥Q**R************i*****9ifi**9**fi**D*i***R*****E!****R*1fl********fl*i***/ } fl end method closeFiles f’****ow***eoo**ikoo****o#**fikofi***took*kro***ntoo**aw.***fikow***tt****e’****ot***ktok***to***kt****k!ow***o¢**a * Prepare the Customer collection
i***********ii*#**************i**t**********************t******************f**********t******t*********t******fi fer
* Deserialize all objects from serialized Customer file
* As each object is deserialised (read), add it to the collection holding Customer objects


Customer target; I! 'template' for search process
Customar found: fl 'holding space' for the located Customer ohjeat
f: * Set up for Customer search.
* The "important" piece is the custflumber —> findeuat.nll other information is essentially filler and
* will not be used in the search process.
target = new Customerg findCust,
"blank" ,
"blank" ,
false 3; /**************Rkk*k****F**+*+**********4****i***********************i*************¥**i*i*********#****************
****************** ADD CODE TO SEARCH CUSTOMER COLLECTION FOR DESIRED CUSTOMER OBJECT, ****************** AND TO THEN RETRIEVE THE LOCATED OBJECT. NAME TEE RETRIEVED OBJECT "found" ****ink*ak******titittittiiiiiiiiiiifiiiiiiitight*****ak*ak***akakinhaled:*1:iii“!tttttttiiiiiiii-ii-fititi**********************t
*fi‘*9;*9;*9;*‘Vt*‘VtI”!DI:VtFiri‘kli‘li‘li‘i'fl-i‘ki‘ii‘ii‘i‘i‘i‘i‘i‘i‘fi‘*i‘fi'fi‘fi'iksi'fi‘*5?9t*9t*9;*9;*I!VtIr*‘i—Ir'lr‘k'l-i'********ii‘i‘+i‘*i‘i‘i‘*i‘****i‘**********RSVRIHHIHHPIKI // Print the first repcrt break header
System.cut.printft "%n%-205 %-ZDs Customer Es, TIN BeBn",
found.getFirat{ },
found.getLast[ ),
found.getCustNumber{ ),
fuund.gatTin( ) 1; } catchq CustomerException err J
System.err.printf( "Error searching Customer ListSn“ );
} If and catch
} I! end findCuatomer } I! end class Customerhccountfieport


CustomerAccou ntReport.|ava Import all necessary [and only necessary} classes and interfaces
Declare required objects to read (deserializej the two serialized files
Declare required structures to hold the deserialited objects In openFiles: 0 Produce the code needed to open the two input files and prepare them to be read,
including appropriate exception handling.
0 Note—any exception here should trigger a stack trace print and be 'passed' to the main
method for final disposition.
In closeFiles:
0 Produce the code needed to close the two input files, including appropriate exception
0 Note— any exception here should trigger a stack trace print and be 'passed' to the main
method for final disposition.
In processReport: Make no changes.
In prepCustomerCollection:
0 Write loop to deserialize all Customer objects
I Store each object in the appropriate structure onoe deserialized
0 Once all objects have been stored in the structure, sort those objects:
. Ascending order
I Based on custhlumber
0 Include appropriate exception handling. Unanticipated problems should be elevated to
the main method for final disposition.
In prepSecurityCollection:
0 Write loop to deserlalize all Security objects
- Store each object In the appropriate structure onoe deserlallzed
0 Once all objects have been stored in the structure, sort those objects:
I Ascending order
I Based on custNumber 0 Include appropriate exception handling. Unantlclpated problems should be elevated to
the main method for final disposition.
In reportEqui‘tyPosit ions, write the declarations for the following:
o Declare an iterator for use with the Security collection
0 Using that iterator, retrieve a Security object; assign it to reference equity
0 Based on the equity object, retrieve the custN um ber value; assign it to reference
In 'FindCustomer, write the code to
0 Search the Customer collection for the desired object
o Retrieve the object
0 Name the retrieved object found Additional Requirements
The submitted code must follow the published Coding Standards.


} f/ and try
catch( IOException ioErr ) fl If there is any error in opening,readingr or closing files I System.err.println( "Ending process.“ 1:
} If and catch
catch( Exception err 3 fl Any/all other exceptions passed up to main
{ System.err.printf( "Serious error. Ending proces. $5", err.getClasa( ).getName{ ] J;
err.printstackTrace[ ]; }// and main f*********fiiki********fi*w**********i******I*********R********************i***********i****R******************** * Open the input files
iti*tfi*ii**ifl*wiflflfi**i**!‘fi‘**fi‘**I'fi'*ii**l‘fi'*l'1'**i‘**l'1'**l‘**I***¥**R**R¥**ifi*iifi*ifi*****fi‘*fll‘9¢Rti*wi***fi**9**ifi*i*f fi-
* Locate the physical file; define it as an input stream; define the input stream as an object stream.
* Prepare to deseralize objects from the file.
public static void openFilea( )
throws IOException { JI'titti‘liiiiti‘lit‘kiit”!itiittiitiittiit‘kiti‘kttiiti‘itkiik‘k‘kii‘kittiitiittiiit”!kiitt‘kiiiitiiit‘titiiittitiiitiittiiti‘ttti
iiitiiit*ii*****it*i***it*i************i**k**i*itkiit’i‘iiii’itiiiti’iiiiii*ii*****i**i***it********i*ii‘iii‘iitiiii‘iik ****************** ADD CODE TO OPEN INPUT FILBS, INCLUDED NECESSARY EXCPETION HANDLING
**i‘*****i-i'ant-id'k'ki*‘ki*Vei-i'*i-i‘sk'ki-i'w*i‘ak'l-i‘i'vtId”:*i‘i'at*******I-i'i‘*i-‘l*éifi'*i-‘k*ii‘fi'ii-i‘t'I-i*i-i‘i‘*‘ki‘*ii‘i‘**i‘*********i**i*******i*t *‘kfi‘9ll'l‘4‘9‘k‘fi‘9d‘i‘4lfl‘k‘ifl’t'l'i‘*Vt‘l‘i‘vt‘ki‘fik'fi‘i‘fi'Vt‘k‘i‘i’t'l‘l‘fi'Vt*‘l‘i’ti‘i‘fi'tV***P*Q*********¥*****ii*i‘k‘i‘w'l'i‘*i'*‘§‘*‘l‘i‘*fli‘l‘*‘k‘i‘**i‘***i‘******4‘******4‘***i
} l/ and Method openFila [iii****ii**tfi**i**ii**i**ii*k$***w*fii**l**i******i**ktk*ifi*R**********fi**iii************i**ii**i**t$*****ifi*ki* * Manage the actual reporting process
ttfiitffixtl'kRt***’xtt’*fi’*RI**t**’li"*ti**t**ti*nt**I!**I'**I**lil**tfikk'flxt’fl*I"*fi’kntflfi't*t’*ktfiit't’klt’ktikflififlt" fu- * Deserialize Customer file; store objects in collection. Sort collection when file is completely deserialized. i
* Deserialize Security file: store objects in collection. Sort collection when file is completely deserialised.


Customer (Serializdm‘el Attributes
m 53:31.; "cilét'Nlir'r'iber'TSt-in} ' E'un-qEE'i'Eigritifie'r'f'Sfi“ c'fiEiEm iHuQ‘GEfi'iEiis 'ifiieiisflii HEEt“E§BT-Eéi'e”?tii3h"fiibdfi
m— Customer's can re - rtln -_ number - 'I'IN. EIN. or SSN; must be 9 dlits Ion:
Customer's last name {orsurname} as per legal identification; If a value is ofiered, it must be
neither null nor blank.
Customer’s first (or given: name as per legal lndentlficaclon. If a value Is offered, it must be
neither null nor blank.
private margin: int Margin Iimitfortrading; expressed as whole dollars,- if eq uel to zero - customer is not
authorized for margin trading. Default value is zero. Negative values are not permitted.
Indicates customer's instructions on dividend reinvestm ent: tme = a utomatic reinvestment;
false = by customer instruction
' fiiiiaTi‘E'E‘Js‘t “n? éfii‘iiifi‘sir’ii’g— Fuiiiisfi‘s'ifiie ' r ’
Id: String.
ll'darne: String,
mama: Sir-Ins.
Ilm: Int. reUp: hoolea n,
fAuHI: buolean }: Customer
public describetustomerl J: String Returns a formater String obJect with a verbose description ofthe Distorner object:
Custom er custltrunber , f‘i rs: Lost.
The account carries a margin limit of slam-"gin _
The account will reinvest dividends as recieued.
The aoccuunt is authorized to trade lfl futures contracts. NOTE: Alternates for the last him lines will read "Dividends will be deposited as cash funds."
lwhen d rip=falsel a rid "The account is not authorized to trade futures contracts.“ [when
utur‘es - false ou hli: toSu'lngi 3: String Returns a formatted String object containing raw values of all Instance varl a bias:
mstomermustflumber tin Last 1 rst mar ‘i n dn‘ a utures NOTE: There an be no null constructor defined forthis class.


Read in TWO serialized files of objects: Customer Security
Store objects in collections — each file/type in a separate collection
Sort each collection into ASCEHDING ORDER by custNumber Process match/merge repor
All Security objects
By Customer (o) 201?, Terri Davis
I I I I I I I I I I I I I I fi**iki*iiiikiti*iii******itiiiikitiii**i*i***i*i**i*iiiiiiiikitiiiiiikiii**i*****i*i*iiii*iiiii**i*i*i**+ii*ikiiti ifiskflale!-**t*i-*iak'k*ak\l-dgf*tirdrsk-k*1:I-*i****i-*i9;I-*1!******i*i-*1:*aktaki-akis!!!**iii-*i-aktat-kkalel-*i******id:inki-*i-ak-ki-aktakI-gtq-al-flfl-akfiiakikakl-fi ****************** ADD NECESSARY IMPORT STATEMENTS HERE
ttktkt**t*t*t*tt*t*t*t********i******i*t*t******i*t******t*t*t**i***i*t****i*i*t****i*t******t*i*i*i******t****** ***i**E*********1R*******ikfl****Tiifi******f********1R*********i******ifik*******i*i******ii********Rf******i**fl**!
public class CustomernccountReport f*i*i*i**i*i*iiii*i*i*i******i*i***ii*i*i*i*i****i*l****i*i***i*iiii*ifiiifi*fii*i*i*i*ii*l*i*ii*i*i*i*i******i*i**i*i
***i***********************************k*i******t*i*********#**************i**********i*********#l*****fl*fi**i**** **************i*** ADD DECLARATIONS FOR INPUT FILES AND COLLECTIONS TO STORE OBJECTS *t*1*1**t*t*t*ttitwi*t*1*1txtkt*t*xt*t*tkt*1r***t*t****t*t*thtrite*t*t****t*t*?**f*t*I*1*1**r*t*l*1**r*fit*t***t
i**i**********i*i********iki****iiifi********i******1*********ki*******fik*i*****i*i*i****ikiffl***k*********ikiif*fl [i*i****+****i*i*i*i******i*i***t**i*i*i******i*i****i*i***i*i***********i*i*****ti*i*t*i**i*i*i*i**i*****t**** * main method
iititi*i*iiiititititiktiiiti*ttiitiiiitiifiiitiii*tititiiitiiiiti*i*titiiitiiitiititikiiittititiniitititikiiti/ public static void main[ 5tring args] { f9
* The try block executes the following processes:
* Open input files
* create and output report entries
* close input files
{ openFilest}:
} I! end try
catcht IDException icErr ) if If there is any error in opening,reading, or closing files


Expected Report Output Charlotte Blackwood Customer 6616661, TIN 951874632
Stock HUEY carries a cost basis of $1,212.66
HutualFund POPY carries a cost basis of $2,176.99 Mike Metcalf Customer 1666666, TIH 345675961
MutualFund MHF carries a cost basis 06 $586,255.66 Pete Mitchell Customer 1666661, TIN 234567696
Stock ORB carries a cost basis of $23,766.66
HutualFund TBMH carries a cost basis of $1,563.66 Penny Benjamin Customer 1666663, TIN 65432198?
Stock TSLA carries a cost basis of $12,229.56
Chip Sylvester Customer 1666664, TIN 967321456 HutualFund MMF carries a cost basis of $2,567.56
HutualFund TBMM carries a cost basis of $264,111.42 5am wells Customer 4669999, TIN 951263874
Stock BKSH carries a cost basis of $16,135.26 Rick Neven Customer 5669999, TIN 951236654
Stock CARA carries a cost basis of $3,765.66 Tom Jordan Customer 8661665, TIN 326874591
MutualFund CAP2 carries a cost basis of $3,394.56 ***** END OF EQUITY REPORT *****



Recently Asked Questions

Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.


Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question