Question
DESCRIPTION: 1) Get a copy of structSearch program and the phony.422 data file from the class website. 2) Modify the program as needed to make
DESCRIPTION: 1) Get a copy of structSearch program and the phony.422 data file from the class website. 2) Modify the program as needed to make it run and search for a phone number from phony.422 3) Modify the program to permit the user to enter a customer name or a customer phone number for the search. Ignore case when doing the search for the customer name. Use the stricmp function to compare the customer name entered at the keyboard with the customer name from the file. 4) a. search for a record near the beginning of the list, b. search for a record anywhere in the middle of the list, c. search for the record near the end of the list. NOTE: If your compiler does not have strcmp, you may need to use _strcmp . If your compiler does not have stricmp, you may need to use _stricmp or strcasecmp. DISCUSSION: 2) Complete the DISCUSSION section. It does not need to be long, but it needs to be complete. 2a) What did you do to develop the program? ("Followed the Directions" is not a complete description) 2b) What problems did you have and how did you overcome the problems? 2c) Compare the number of searches when looking for a data record near the beginning, the midle or near the end of the list. Which search method would give the best results when the search could be anywhere in the list? PROGRAM OUTPUT: 3) Show screen shots for at least THREE searches: a. search for a record near the beginning of the list, b. search for a record anywhere in the middle of the list, c. search for the record near the end of the list. Refer to previous lab assignments for instructions on how to capture a screen or portions of a screen for either the PC or a Mac
Data needed:
CAR TRANSMISSION REPAIR..........228-5141 Johnston Mary....................230-6909 Houston Dan......................233-8123 Ha Nguyen........................234-4238 BANK OF AMAZON...................242-7821 Ha Kelly.........................249-9802 Estrada Manuel...................251-6725 Dang Dong........................259-6858 BOOKS FOR SALE...................263-9699 Hendrix Daniel...................266-0113 CALIFORNIA TEACHERS UNION........266-9133 Global Resarch Corp..............268-3823 Brooks Sally.....................269-7628 DENTAL CONCEPTS..................271-7493 Johnston Steve...................277-4785 Kelly Dan........................279-8731 Hernandez Jose...................281-7664 International Flower Shops.......283-2587 Cupertino Flowers and Trinkets...283-8323 Bobbit Larry MD..................286-7385 Aitken Charles...................288-3903 Gonzales Pablo...................292-6086 Hunter Paul......................295-5456 BLOSSOM HILL AUTO PARTS..........296-2103 Gallagher Mary...................298-7125 BLOSSOM HILL REAL ESTATE.........320-3716 Javier Luis......................324-2666 Dang Kanh........................327-7222 Browne Richard MD................330-5709 LUCKY STORES.....................336-4458 Bush Keith.......................337-3741 Bush Sandy.......................337-9118 Brooks Paul......................340-2482 Brownfield Derick................346-1583 Brown Kelly......................355-6572 Allop Jose.......................356-4698 Dang Quang.......................357-6746 Black Marcie.....................358-4136 Brooks Kent......................362-5430 Gallagher Suzy...................370-6133 CAKE STORE.......................373-2564 DENTAL OFFICE....................373-5009 Diet Delight.....................374-3445 FRANK'S TERMITE KILLERS..........379-6574 DOMINIQUE'S PIZZA................380-9207 Javier Maira.....................381-5865 CASA DE BANJO....................381-6108 INTERNATIONAL HOUSE OF FOOD......386-1102 Barber Larry.....................386-5287 Baird Chuck & Sally..............390-9086 Duncan Mark......................391-6771 Black Donald.....................392-1164 Abraham Sally....................421-5534 Kelly E..........................424-8749 Brown Richard....................425-9635 Gonzales Flower Shoppe...........429-5277 Ha Fong..........................431-4868 Blackmore Mark...................431-7590 Bettencourt Fredrica.............435-3074 CASA DE GUITAR...................438-8929 Gallagher Joe....................445-4811 Gonzales Luis....................446-3320 Jordan Marueen...................448-6432 Estrada Leo......................455-5540 BLUE CRUTCH INSURANCE............456-9915 Campbell Charles.................457-6897 Lambert Richard..................459-7789 BOCCONE LAW FIRM.................481-3258 CALIFORNIA STATE OFFICES.........483-4197 Bettencourt Rosanne..............496-9050 Estrada William..................497-4554 COIN LAUNDRY.....................497-5341 INTERNATIONAL SERVICES...........498-2507 Bell Roger.......................522-1192 Brown Armando....................523-4130 Brown Larry......................527-6956 Campbell Motel & Storage.........530-7878 Jordan David.....................534-7586 A BETTER COOKIE..................542-2675 CAPRET INSTALLATION..............542-4392 DOMINIQUE'S PIZZA................548-9350 BANK OF THE WORLD................552-4939 Bates Fred.......................554-3111 ABLE RENT-A-COMPUTER.............555-1298 Blackburn Randall................556-2645 CHILDREN'S AID SOCIETY...........557-3290 Ha Sang..........................557-8678 A VIDEO RENTAL...................566-5819 Allen Steve......................568-7022 Flowers of San Jose..............571-7149 Houston John.....................585-1526 Duncan Kari......................586-4612 Balovich A.......................590-1163 BRADY FLOWERLAND.................597-1831 Brewer Daryl.....................597-5152 Abula Michael....................622-4649 Cash Johnny......................627-6226 Boucher Victor...................628-7419 CAMBRIAN BANK....................629-5512 BANK OF THE CITY.................633-1655 Burger Lance.....................635-2036 BRAKE FIXERS.....................636-8425 AMDAHL CORPORATION...............637-3150 Austin JR........................637-5372 Javier Jose......................639-7102 CALIFORNIA MOTOR GARAGE..........649-5798 CASA DE MUSIC....................649-9241 ACTION MOVIES....................650-2286 CALIFORNIA SMOG REPAIR...........651-5486 Bates Joan MD....................653-9446 Browne Alice.....................662-2438 Duncan Jerry.....................665-4015 BOOKSTORE THE....................666-6481 Bailey Robert....................668-1985 Dingy Motel......................671-2051 BANK OF DEPOSITS.................672-7248 DENTAL REPAIRS...................673-9833 Chamber of Commerce..............674-5650 Alexander Lonnie.................675-2376 Gonzales Maria...................679-1401 Joshston Bill....................682-4395 Howard Steve.....................683-7553 Bettencourt Jim..................684-7641 Diet Easliy......................685-1552 Aaker Charles....................685-3921 COIN WASH........................691-6877 CALIFORNIA BANK AND TRUST........697-3974 Brown Robert.....................699-8318 Brooks Richard...................721-2920 Browne Sylvia....................721-6627 Diet Alert.......................721-8081 Bailey Michael...................721-8536 A TOUCH OF CRASS.................722-1379 BOSTON LAW OFFICES...............723-6307 Blackburn Thomas.................726-3399 Diet With Rachel.................726-4578 Duncan William...................737-7233 Brown Richard....................741-5592 DOMINIQUE'S PIZZA................741-9008 Campbell Flowers and Trinkets....742-6903 Duncan Sam.......................749-6177 CHAPTER 13 LAW OFFICE............759-9581 Clark Kent.......................760-1760 C & F Carpet Store...............762-6109 Hernandez A......................764-3057 Gonzales Joe.....................764-9692 Ha James.........................767-1276 Ballard Gary.....................768-5359 Cat Store........................785-2110 Barber Sally.....................785-5458 CAR MUSIC FACTORY................787-5748 Estrada Rene.....................787-8014 Black Ralph & Mindy..............789-3805 Houston Jim......................796-1122 Gonzales Alfredo.................797-8236 Brewer Randall...................797-9495 CALIFORNIA VETERANS..............820-5327 Houston Bill.....................821-3456 Howard Mary......................823-8225 Global Warming Center............823-9036 Fisher's Flower Garden...........824-6209 Brown William....................824-8711 Ha Dave..........................825-3791 Estrada David MD.................827-4030 Boccone Richard..................837-4768 Howard Alfred....................840-1540 Bailey Michael...................844-5196 Dang Hoang.......................844-5875 Addams Brent.....................844-8936 Flowers of Milpitas..............845-1679 Brewer Manny.....................845-3374 Dang Trang.......................852-5968 BERRYESSA DOCTOR'S OFFICE........857-8262 Brown Roger......................859-6337 Bush Rachel......................863-6495 Duncan Miranda...................864-6711 INTERNATIONAL COMMERCE COMISSION.865-8486 CASA DE HARP.....................871-7800 Austin Nellie....................873-6368 Fernandez Chuck..................873-7779 Gonzales Jose....................874-8734 Gonzales Anthony.................876-6414 Kelly George MD..................889-8693 Duncan Ester.....................891-1230 Brownell J R.....................897-8821 McElroy Daniel...................963-4415 // Search_Struct_Binary.cpp // #include "stdafx.h" // only for Microsoft Visual C++ #include #include // you may need this include to use stricmp or strcasecmp for C++ #include // -- or you may need this one for C using namespace std; typedef struct S_STATE_LIST { char Abbreviation[3]; char StateName[15]; } States; States StateList [] = { {"AK", "Alaska"}, {"AL", "Alabama"}, {"AR", "Arkansas"}, {"AZ", "Arizona"}, {"CA", "California"}, {"CO", "Colorado"}, {"CT", "Connecticut"}, {"DE", "Delaware"}, {"FL", "Florida"}, {"GA", "Georgia"}, {"HI", "Hawaii"}, {"IA", "Iowa"}, {"ID", "Idaho"}, {"IL", "Illinois"}, {"IN", "Indiana"}, {"KS", "Kansas"}, {"KY", "Kentucky"}, {"LA", "Louisiana"}, {"MA", "Massachusetts"}, {"MD", "Maryland"}, {"ME", "Maine"}, {"MI", "Michigan"}, {"MN", "Minnesota"}, {"MO", "Missouri"}, {"MS", "Mississippi"}, {"MT", "Montana"}, {"NC", "North Carolina"}, {"ND", "North Dakota"}, {"NE", "Nebraska"}, {"NH", "New Hampshire"}, {"NJ", "New Jersey"}, {"NM", "New Mexico"}, {"NV", "Nevada"}, {"NY", "New York"}, {"OH", "Ohio"}, {"OK", "Oklahoma"}, {"OR", "Oregon"}, {"PA", "Pennsylvania"}, {"RI", "Rhode Island"}, {"SC", "South Carolina"}, {"SD", "South Dakota"}, {"TN", "Tennessee"}, {"TX", "Texas"}, {"UT", "Utah"}, {"VA", "Virginia"}, {"VT", "Vermont"}, {"WA", "Washington"}, {"WI", "Wisconsin"}, {"WV", "West Virginia"}, {"WY", "Wyoming"} }; int main(int argc, char* argv[]) { int length = 50; char Selection[10]; cout << "Enter the state abbreviation: "; cin >> Selection; // Binary Search int imin = 0; // start index for the current search int imax = length-1; // end index for the current search int imid; // midpoint for roughly equal parts int tries=0; // counter to see efficency bool found = false; while ( imax >= imin && !found ) { tries++; imid = (imin + imax) / 2; // Note: your compiler may use _stricmp or strcasecmp instead of _stricmp if (stricmp(Selection, StateList[imid].Abbreviation) == 0 ) // found { found = true; } // Note: your compiler may use _stricmp or strcasecmp instead of stricmp // if need to go lower, change upper limit to search lower subarray else if (stricmp(Selection, StateList[imid].Abbreviation) < 0 ) { imax = imid - 1; } // if need to go higher, change lower limit to search upper subarray else { imin = imid + 1; } } if (found) cout << StateList[imid].StateName << " in " << tries << " tries" << endl; else cout << "Not Found" << endl; return 0; }
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