attached
Adsız Assignment71 (300Points) PARTI Question1 Inthisquestion,youwillreadwordsfromafileandplacethemintoanarrayoftype string. 1- Makeadatatextfile“words.txt”–thatcontainsonewordoneachline.Useat least20words. 2- Nowwriteaprogramthatreadsthewordsinthefileintoanarrayofstrings (arepeatedwordshouldnotbeinsertedintothearray–yourprogram shouldnotallowthatandyoushouldmakesureyourdatafilehasduplicate wordstotestthisfunctionality).Makeyourarraysizeenoughtohold1000 words.Toreadthewordsintothearray,youshouldmakeafunctionthat takesastringarray,adatasizeinteger(dsize)byreferenceandanifstream– pleaselookattheexamplewedidinclass. 3- Declareyourarrayandfilestreamsinmainandcallthefunctionthatreads thedataintothearray. 4- WriteaprintArrayfunctionthattakesastringarray,thedsizeandan ostreamobjectsothatyoucouldprinttotheconsoleortoanoutputfile. 5- PrintyourarrayfrommainbycallingtheprintArrayfunction–oncetothe consoleandoncetoafile“wordsoutput.txt”. 6- UsetheselectionSortAlgorithmthatwecoveredinclasstosortthearray. 7- Repeat#5andmakesurethearrayissorted. 8- Findthemaximumstringandtheminimumstringinthearray(remember arraysarecomparedbasedontheASCIIvalue). 9- Writeafunctionthattakesastringandconvertseverycharacterofitto uppercase.Nowcallthatfunctionfromafunctionthatyoupassthearrayand dsizeto,touppercaseallwordsinthearray(convertallwordsinthearrayto uppercaseletter)andcallthatfrommainpassingyourarraytothatfunction. Printthearray. Question2 A. Inthisquestion,youwillreadtwodatafilesthatincludeintegersintotwo differentarrays–thesamewaywedidinclass(butwearedoingtoarrays here).Duplicatesareok. 1- Afteryoureadthedataintothearray(useonefunctionthattakesanint arrayandadsizebyreferencejustlikewedidinclass,andcallthatfrom maintofillbotharrays). 1Allnumbersinthisassignmentshouldbeformattedto2decimalpoints. 2- IncludeaprintArrayfunctionsothatyoucouldprintthetwoarrays.Use arraysize1000. 3- Useasortalgorithmtosortbotharrays. 4- NowwriteacompareOrderfunctionthattakestwoarraysandtheirdata sizes.Ifthedatasizeisthesameandeveryelementinthefirstarrayisequal toelementinthesamecorrespondingpositioninthesecondarray(both sorted)–thenthearraysareequal(return0).Iftheveryfirstelementthatis differentislargerinonearraythantheotherarraythenthefirstarrayis larger(return1)otherwise(return-1).Ifthedsizesaredifferent,thelonger arrayislarger(return1ifarray1islargerthanarray2and-1otherwise). 5- CallthecompareOrderfunctionfrommainpassingyourtwoarraysandtheir correspondingdsizesandgiveappropriatemessages.(PleaseseeHint- required). 6- NowwriteacompareSumtocomparethetwoarraysbasedonthesumof theirelements–followthesamethemeofreturning0,1or-1–andcallfrom mainwithappropriatemessaging(pleaseseeHint-required). B. Makeanewprogram.Copyallyourcodeanditchangeitsothatitusesa vectorinsteadofanarray.Youdon’thavetouseapresetsizeforthevector. Hint:InsteadofcallingcompareOrderandCompareSumandincludinglogiccodefor messaginginmain(ugly),writeavoidwrapperfunctioncomparethatwouldtakea comparetype,thearraysandtheirdsizesandwillcalltheappropriatecompare functionwiththearraysandthedsizesandproducetheappropriatemessaging). PartII Your task is to read a file that consists of credit card accounts, calculate interest charges,updatethebalanceandwritetheinformationtoanewfile. Tasks A. Openatextfileandtypeatleasttenrecords(eachfullrecordofanaccount should be on a separate line) 2 . Each record will consist of the following items separatedbyspaces: 1- CreditCard(16digits–nodashesorspaces–youshouldconsidertheseas charactersbecauseyouwillnotdoanyarithmeticoperationsoncreditcard numbers).Youshoulduseastringvariableforcreditcardnumber. 2- FirstName. 3- LastName. 4- InterestRate(between11.4%and24.9%) 2Pleasedon’tuseTextEditontheMactocreateyourtextdata.DownloadSublime andusethatasyourtexteditor–otherwise,youmayhaveproblems. 5- BalancefromPreviousstatement. 6- Currentcharges. Savethefileas“balances.txt”3. B. NowwriteaC++programthatwouldreadeachrecord,calculatetheinterest chargesonthepreviousbalanceforthecurrentperiod(onemonth),addthecurrent charges,calculate thenewbalanceandwriteout thesamerecord formatwiththe newly calculated balance (and 0 current charges of course). Name the file “newbalance.txt”. You should use a function that returns a double to make the calculationof thenewbalance.Your functionshould takeparametersof (interest rate,previousbalance, andcurrent charges)and returnnewbalance.Pleasedon’t forgettodividetheinterestrateby12togetthemonthlyrate. C.Runyourprogram.Pasteyourcodeintoaworddocument,takescreenshots(no phone pictures) of the output. Please upload theword document alongwith your “balance.txt”and“newbalance.txt”filestoBB. PartIII 1- Write a struct or a class PersonType which will have firstName,lastName,eID(asanint),salary,andtitle 2- WriteastructoraclassCompanyTypethatwillhaveancID, Name,City,StateandEmployeeasanarrayofPersonType– letuslimitourexercisetocompaniesofsize1000orless– andthenumberofemployeesasmembers. 3- Hide all variables for EmployeeType and CompanyType – exceptthearrayinCompamyType. 4- Writeparameterizedconstructors foreachstruct/class–a personcanbeinstantiatedbyallitsattributesexceptsalary and title. A company can be instantiated by ID, name and current number of employees (startwith 0 at the time of instantiation). 5- Writeappropriategettersandsettersforeach.Toreturna list of the employees of the company, you obviously can’t returnanarray.Butifyouuseavectoryoucould.Ignorethat particular getter – and I will do that part with you on 3Pleasemakesureyourcursorisattheendofthelastrecordnotatthebeginningof anewline. Thursday. 6- Add a void method hire to CompanyType that takes as parameter a PersonType, salary, title. Themethod should addanemployeetothearrayofemployeesofthatcompany, andsetthesalaryandtitleofthatPerson. 7- Add a method to Employee called giveRaise with a percentage. 8- Inmain()– a. Makeadatafilethatincludesemployees,andanother one that includes companies, load them in, and Instantiate a the Companies and Persons –making surethatanemployeeworksforanexistingcompany in the company file – if an employee works for a companythatdoesnotexistinthecompanyfile,you needtoaddthecompany–yourlogicshouldbeable todothis. b. DeclareaanarrayoravectorofCompanyTypeand addallcompaniestothearrayorvector. c. Loop through companies and print each company followedbytheemployeesworkinginthecompany. d. Printtheavgsalarypercompany. e. Printthetotalavgsalaryacrosscompanies. f. Assume each companywill give a raise that ranges between3%-5%.Assignsucharaisetoeachcompany randomly and then give its employees a raise, and redopartsdande. g. Sortallemployeesofallcompaniesbysalary h. Sortallcompaniesbytheavgoftheirsalaries. i. Write a method or methods to have an employee movefromonecompanytoanother. Submission 1- Submityourcppfilespastedinaworddocument.Pastethecodenotan image. 2- Submitthedatafilesyouusedseparatelyasfilesnotpastedintheword document. 3- Includeascreenshotofeveryoutputforeachcase.Noscreenshots= ZERO.Youmustpastethescreenshotwiththeappropriatequestionin theworddocument–Iwillnotacceptimagefiles.Youneedtofollow instructionsofhowtosubmit. 4- ForQuestion2ofPartI,pleasemakedifferentsetsoftwodatafilesto testyourcodeforallcases.