Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Programming Project 2 Part A ArrayLists Part A - ArrayLists adds Excel (Unlicensed Product) Home Insert Page Layout Formulas Data Review View Help Tell me

Programming Project 2 Part A

ArrayLists Part A - ArrayLists

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

adds Excel (Unlicensed Product) Home Insert Page Layout Formulas Data Review View Help Tell me what you want to do Calibri . Wrap Text General E Copy Paste Merge & Center 40 00 Conditional Format as Cell 00 .0 Format PainterBIUA Formatting- Table- Styles Clipboard Font Alignment Number x 627 Walford Ave first name last name emailcompany address city Char Paul county state zip phone1 phone2 web KinesCharHines W Tc Indu: 3 Aspen St Worcester Worcester MA CartanPaul.carta Box, J Calv 9390 S Ho Albany Dougherty GA Lary Hagele Mhagele@ Ninas Indi 627 WafoDalas Dallas TX Frey 1602 508-429-8 508-843-1 http://www.wtcindustriesinc.com 31701 229-735-3 229-365-9 http://www.boxjcalvinesq.com 32922 321-749-4 321-632-4 http://www.matriccianialbertjjr.com 75227 214-339-1 214-225-5 http://www.ninasindiangrsvideos.com 11758 516-948-5 516-357-3 http://www.woodbridgefreepubliclibrary.com Joe lary@ Matriccian 8597 W NE Cocoa Brevard FL Mark Bill Bill_frey@ Woodbrid 54169 N M Massapeqi Nassau NY members Excel (Unlicensed Product) File Home Insert Page Layout Formulas Data Review View Help Tell me what you want to do Calibri General B 1 u . O-A . | s-96 , Conditional Format as . Cell FormattingTableStyles Merge & Center . Format Painter Clipboard A1 first name I) 1 first_namel last_name em company_address city 2 James Butt county state Zl phone1phoe2 web 70116 504-621-8 504-845-1 http://www.bentonjohnbjr.com 48116 810-292-9 810-374-9 http://www.chanayjeffreyaesq.com jbutt@gma Benton, Jo 6649 N Blu New Orlea Orleans LA 3 Josephine Darakjy josephine_ Chanay, Je 4 B Blue Ri Brighton Livingston MI Venere art@vener Chemel, Ja8 W Cerrit Bridgeport Gloucestei NJ 5 Lenna Paprocki lpaprocki@ Feltz Printi 639 Main SAnchorage Anchorage AK 6 Donette Foller donette.fc Printing Dii 34 Center Hamilton Butler OH 7 Simona Morasca simona@n Chapman, 3 Mcauley Ashland Ashland OH 8014 856-636-8 856-264-4 http://www.chemeljameslcpa.com 99501 907-385-4 907-921-2 http://www.feltzprintingservice.com 45011 513-570-1 513-549-4 http://www.printingdimensions.com 44805 419-503-2 419-800-6 http://www.chapmanrosseesq.com 60632 773-573-6 773-924-8 http://www.morlongassociates.com 95111 408-752-3 408-813-1 http://www.commercialpress.com 57105 605-414-2 605-794-4 http://www.truhlarandtruhlarattys.com 21224 410-655-8 410-804-4 http://www.kingchristopheraesq.com 19443 215-874-1 215-422-8 http://www.dorljamesjesq.comm 11953 631-335-3 631-677-3 http://www.rangoniofflorence.com 90034 310-498-5 310-254-3 http://www.feinerbros.com 44023 440-780-8 440-579-7 http://www.buckleymillerwright.com 78045 956-537-6 956-841-7 http://www.rousseauxmichaelesq.com 85013 602-277-4 602-953-6 http://www.centurycommunications.com 37110 931-313-9 931-235-7 http://www.boltonwilburesq.com 53207 414-661-9 414-377-2 http://www.tmbyxbeecompanypc.com 48180 313-288-7 313-341-4 http://www.farmersinsurancegroup.com 61109 815-828-2 815-426-5 http://www.postboxservicesplus.com 19014 610-545-3 610-492-4 http://www.sportenart.com 95111 408-540-1 408-813-4 http://www.cnetworkinc.comm 75062 972-303-9972-896-4 http://www.ingallsdonaldresq.com 12204 518-966-7518-448-8 http://www.franklinpeterlesq.com Art 8 Mitsue Tollner mitsue_tol Morlong A 7 Eads St Chicago Cook 9 Leota Diard leota@hot Commerci 7 W Jacksc San Jose Santa Clar. CA Wiesersage_wies Truhlar An 5 Boston A Sioux Falls Minnehah SD Marrierkris@gmai King, Christ 228 Runan Baltimore Baltimore MD 12 Minna Aigon minna_am Dorl, Jame 2371 Jerro Kulpsville Montgome PA Maclead amaclead( Rangoni O 37275 St FMiddle Isla Suffolk NY Kiky a kik:y.caa ir Bro hs A:ls CA Akl 16 Cammy Albares calbares@Rousseaux 56 E More Laredo WebbTX 17 Mattie Poquette mattie@ac Century Cc 73 State R Phoenix Maricopa AZ 18 Meaghan Garufi meaghan@Bolton, Wi 69734 E C Mc Minnvi Warren TN 19 Gladys Rim gladys.rim T M Byxbe 322 New HMilwaukee Milwaukee Whobrey yuki_whot Farmers In 1 State Ro Taylor Wayne MI 23 Veronika Inouye vinouye@ C4 Netwo 6 Greenlea San Jose Santa Clar CA WillardKolmetz willard@h Ingalls, Do 618 W Yak Irving Dallas TX Maryann Royster mroyster@ Franklin, P 74 S West Albany Albany NY lusarski alisha@slu Wtlz Powe 3273 State Middlesex Middlesex NJ 25 6 /32.458132.435.http://yrww.widzp()weniim.com 662-6 715-530-9 http://www.ledeckydavidesq.com All Cha Ezekiel Chui ezekiel@cl Sider, Don. 2 Cedar Av Easton TalbotMD 90991 Tho New York New York NY bfigeroa@ Clark, Rich 386 9th Av Conroe Montgome TX GG218 1:1 3 31913- 2py 1 hting www.prufessor'alinnang: "c.ex pm 21601 410-669-1 410-235-8 http://www.siderdonaldcesq.com 10011 212-582-4 212-934-5 http://www.upullit.com 77301 936-336-3 936-597-3 http://www.clarkrichardcpa.com Bernardo Figeroa removes - Excel (Unlicensed Product) File Insert Page Layout Formulas Data Review View Help Tell me what you want to do Home Calibri ab Wrap Text General Copy Paste B 1 u-1.1Cr. A Merge & Center. | $. % , 2 | Conditional Format as Cell | Insert Format Painter Formatting TableStyles Styles Clipboard Font Alignment Number A1 firstname - C: t) 1 first_namelast_name email company_address city 2 Sage Wieser sage_wies Truhlar An 5 Boston A Sioux Falls Minnehaha SD 3 Yuki Whobrey yuki_ whot rm n1 State Ro Taylor Wayne MI 4 Willow uskowkusko@-U Pull It 90991 Tho New York New York NY 5 Valentine Gillian valentine_ Fbs Busine 775 W 17t San Antoni Bexar TX 6 Emerson Bowley emerson.b Knights Inr 762 S Mair Madison D W 7Delmy Ale delmy.ahle Wye Techr65895 S 1 Providence Providence RI 8 lene Eroman ilene.erom Robinson, 2853 S Cer Glen Burni Anne Arun MD 9 Viva Toelkes viva.toelke Mark Iv Pri 4284 Dorit Chicago Cook IL 0 Stephen Emigh stephen_e Sharp, J De 3777 E Ric Akron Summi OH 1Lisha Centini lisha@-cer Industrial 64 5th Ave Mc Lean Fairfax VA county state zip phone1 phone2 web 57105 605-414-2 605-794-4 http://www.truhlarandtruhlarattys.com 48180 313-288-7 313-341-4 http://www.farmersinsurancegroup.com 10011 212-582-4 212-934-5 http://www.upullit.com 78204 210-812-9 210-300-6 http://www.fbsbusinessfinance.com 53711 608-336-7 608-658-7 http://www.knightsinn.com 909 401-458-2 401-559-8 http://www.wyetechnologiesinc.com 21061 410-914-9 410-937-4 http://www.robinsonwilliamjesq.com 60647 773-446-5 773-352-3 http://www.markivpressltd.com 4302 330-537-5 330-700-2 http://www.sharpjdanielesq.com 22102 703-235-3 703-475-7 http://www.industrialpapershreddersinc.com Membership_Processor - Notepad File Edit Format View Help import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.scanner; public class Membership_Processor f public static void main(string[] args) throws FileNotFoundException { PartA) 2 Always add a useful Javadoc method header Give me a preview of what the function does Tell me what to look for in the function public static void PartA() throws FileNotFoundException { ArrayList membership readNames(); System . out.println(string . format ("Read Total of %d names", membership. Size())); * Reads file of names * @return ArrayList of Person class * @throws FileNotFoundException public static ArrayList readNames() throws FileNotFoundException { // Open scanner on file "members.csv" File f new File("members.csv"); Scanner sc new Scanner(f); // TODO: create ArrayList of Person class variable p // Discard first line it's the headers "first name last name email" etc sc.nextline(); // Loop through lines of the file while (sc.hasNextLine()) [ // Get the next line String line - sc.nextline(); Scanner scLine -new Scanner(line); // This allows us to use comma as the delimiter instead of whitespace scLine.useDelimiter(","); // Scan the line for the names & emails string first = scLine . next(); String last scLine.next(); String email -scLine.next(); // TODO: put the person into the ArrayList Membership Processor Notepad File Edit Format View Help /I TODO: return the ArrayList you defined return new ArrayList(); * Testing code - do not modify @param membership public static void testPartA(ArrayList membership) { // Test for correct total # of names if (membership.size() !=445) { System.out.println("Wrong number of names. There should be 445 after all removals and adds"); return; // Test all 10 names removed for (Person p membership) if (p.getEmail().contains("-")) ( System . out, printin(String . format ("oops didn't remove person %s %s %s", p.get FirstName(), - p.getLastName(), p.getEmail())); return; // Test that only 5 names added int count for (Person p membership) if (p.getEmail().contains("*")) count++; if (count != 5) { System.out.println("didn't add the right number of names"); return, // Check sorting & overall work at specific random items int[] memberindexes = { 0, 10, 20, 30, 40, 400 }; tring] expectedEmails- { "Bill frey@frey.com**, "alaine_bergesen@cox.net", "amber monarrez@monarrez.org", "apinilla@cox.net", "barrett.toyama@toyama.org", "tasia andreason@yahoo.com" j; for (int = 0; i removes" to verify you read 10 removes. In the next steps you will take each of the removes, look for it in the membership, and remove it if found or print an error if not found. For Person class objects, we choose to use email names to test for equality because these are unique to a Person. o o Run the code. Did you find any of the 10 names to delete? Implement the Comparable interface on the Person class. Modify the Person class declaration to tell Java it will support the Comparable interface. Note this is parameterized" which means you need to put the object type in thebrackets just like you do for ArrayList. Note the red 'x' reminding you that you must now add the compareTo method to the Person class. You must exactly match the compareTo interface definition (function name, parameters, return type). Test only the email field and matclh the compareTo interface return type definition. Now, replace .equals with .compareTo in your nested loops written above for removed in the above step. o o Add a print statement "Total of>names after removals" and verify you removed 10 Persons and now only have 440 left. Add a print statement "Total of names after removals" and verify you removed 10 Persons and now only have 440 left. Add Names o Add another new call to readNames ("adds.csv"). Call this returned ArrayList "adds" Add a print statement "Read Total of adds" and verify you read 5 adds. Write another loop similar to removes. For each member to be added, check for an existing member with the same last name only, and add it immediately after that member. Note this is a different criterion than used for the removes. Make sure to only add each name once. Print a message if you can't find a name and include the email name you're adding. o o Print out "Total of names after adding" and verify it's 445. Sort Now that you have implemented Comparable you can sort the list without having to write almost anything. Write the code to use the Collections class to sort the ArrayList. o *Check your work Add a call from partA() to testPartA() to double check your work. This is similar to the types of tests Practicelt runs on your code. If you have errors use the debugger to see where the problem is exactly in your data and work backwards to fix. o o Check the total number of names is correct at each step o Check your compareTo is sorting based on email names Check you are not accidentally insert or removing more than once (there are names to trip you up if you should not take care of this) o Use intelligent variable names. Intelligently naming all your variables can make the difference between readable bug-free code and illegible broken code. By convention, classes should begin with Uppercase letters, while regular variables should begin with lowercase letters. . * return the firstName public String getFirstName() { return this.firstName; param firstName the firstName to set public void setFirstName(String firstName) { this. firstName = firstName ; * return the lastName public string getLastName() [ return this.lastName * @param lastName the lastName to set public void setLastName (String lastName) this.lastNamelastName; @return the email public String getEmail() return this.email; *@param email the email to set public void setEmail (String email) ( this.email - email; * Print out the name public string tostring) return "Person [firstName"this.firstName ", lastName-" this.lastName", email-"this.email + "]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Objects And Databases International Symposium Sophia Antipolis France June 13 2000 Revised Papers Lncs 1944

Authors: Klaus R. Dittrich ,Giovanna Guerrini ,Isabella Merlo ,Marta Oliva ,M. Elena Rodriguez

2001st Edition

3540416641, 978-3540416647

More Books

Students also viewed these Databases questions

Question

1.Which are projected Teaching aids in advance learning system?

Answered: 1 week ago

Question

What are the classifications of Bank?

Answered: 1 week ago