The program should take user input for name of a text file and the string to...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
The program should take user input for name of a text file and the string to be searched in it. The file has semi-colon separated values. Each row has data about books. The output should show the rows in which the search string appears. It should also show how many rows have the search string in them. The search is supposed to be case-insensitive. Create a file named BookList.txt that has data about books - Title, Author(s), Pages, and Publisher in a semi-colon separated values format, as shown below: Good to Great; Jim Collins; 300; Harper Business; Outliers; Malcolm Gladwell; 336; Back Bay Books; Blink; Malcolm Gladwell; 296; Back Bay Books; The 7 Habits of Highly Effective People; Stephen Covey; 432; Simon & Schuster; Core Java Volume 1; Cay S. Horstmann, Gary Cornell; 836; Prentice Hall; Core Java Volume 2; Cay S. Horstmann, Gary Cornell; 1152; Prentice Hall; The following screenshots show how the program should flow in terms of input and output Enter the file name: Booklist.txt Enter what you are looking for people Found records: 1 The 7 Habits of Highly Effective People; Stephen Covey; 432; Simon & Schuster; Figure 1: Screenshot 1 Enter the file name: BookList.txt Enter what you are looking for Java Found records: 2 Core Java Volume 1; Cay S. Horstmann, Gary Cornell; 836; Prentice Hall; Core Java Volume 2; Cay S. Horstmann, Gary Cornell; 1152; Prentice Hall; Figure 2: Screenshot 2 Enter the file name: BookList.txt Enter what you are looking for blah blah Found records: Sorry blah blah not found in BookList.txt Figure 3: Screenshot3 Enter the file name: BookList.txt Enter what you are looking for Found records: 6 Good to Great; Jim Collins; 300; Harper Business; Outliers; Malcolm Gladwell; 336; Back Bay Books; Blink; Malcolm Gladwell; 296; Back Bay Books; The 7 Habits of Highly Effective People; Stephen Covey; 432; Simon & Schuster; Core Java Volume 1; Cay S. Horstmann, Gary Cornell; 836; Prentice Hall; Core Java Volume 2; Cay S. Horstmann, Gary Cornell; 1152; Prentice Hall; Hints: Create one class called BookFinder with member variables and methods as shown below. BookFinder ~file Name:String "searchString: String +main(args: String[]):void "getUserInputs(): void ~loadRecords(): StringBuilder "searchRecords(fileContent:StringBuilder): String[] "printOutput(found Records: String[]) Figure 5: Class diagram Member variable or method Description fileName searchString main() getUserInputs() loadRecords() searchRecords() printOutput() Stores file name input by the user Stores search string input by the user Gets the program started and invokes other methods Asks the user to enter two inputs for file name and search string Reads the file and returns a StringBuilder loaded with records Searches for rows that have search string, and returns an array of those rows Prints the output as shown in the sample screenshots above. You may find following String methods helpful. Feel free to explore other options. • String.contains • String.toLowerCase() or String.toUpperCase String.split StringBuilder.append The program should take user input for name of a text file and the string to be searched in it. The file has semi-colon separated values. Each row has data about books. The output should show the rows in which the search string appears. It should also show how many rows have the search string in them. The search is supposed to be case-insensitive. Create a file named BookList.txt that has data about books - Title, Author(s), Pages, and Publisher in a semi-colon separated values format, as shown below: Good to Great; Jim Collins; 300; Harper Business; Outliers; Malcolm Gladwell; 336; Back Bay Books; Blink; Malcolm Gladwell; 296; Back Bay Books; The 7 Habits of Highly Effective People; Stephen Covey; 432; Simon & Schuster; Core Java Volume 1; Cay S. Horstmann, Gary Cornell; 836; Prentice Hall; Core Java Volume 2; Cay S. Horstmann, Gary Cornell; 1152; Prentice Hall; The following screenshots show how the program should flow in terms of input and output Enter the file name: Booklist.txt Enter what you are looking for people Found records: 1 The 7 Habits of Highly Effective People; Stephen Covey; 432; Simon & Schuster; Figure 1: Screenshot 1 Enter the file name: BookList.txt Enter what you are looking for Java Found records: 2 Core Java Volume 1; Cay S. Horstmann, Gary Cornell; 836; Prentice Hall; Core Java Volume 2; Cay S. Horstmann, Gary Cornell; 1152; Prentice Hall; Figure 2: Screenshot 2 Enter the file name: BookList.txt Enter what you are looking for blah blah Found records: Sorry blah blah not found in BookList.txt Figure 3: Screenshot3 Enter the file name: BookList.txt Enter what you are looking for Found records: 6 Good to Great; Jim Collins; 300; Harper Business; Outliers; Malcolm Gladwell; 336; Back Bay Books; Blink; Malcolm Gladwell; 296; Back Bay Books; The 7 Habits of Highly Effective People; Stephen Covey; 432; Simon & Schuster; Core Java Volume 1; Cay S. Horstmann, Gary Cornell; 836; Prentice Hall; Core Java Volume 2; Cay S. Horstmann, Gary Cornell; 1152; Prentice Hall; Hints: Create one class called BookFinder with member variables and methods as shown below. BookFinder ~file Name:String "searchString: String +main(args: String[]):void "getUserInputs(): void ~loadRecords(): StringBuilder "searchRecords(fileContent:StringBuilder): String[] "printOutput(found Records: String[]) Figure 5: Class diagram Member variable or method Description fileName searchString main() getUserInputs() loadRecords() searchRecords() printOutput() Stores file name input by the user Stores search string input by the user Gets the program started and invokes other methods Asks the user to enter two inputs for file name and search string Reads the file and returns a StringBuilder loaded with records Searches for rows that have search string, and returns an array of those rows Prints the output as shown in the sample screenshots above. You may find following String methods helpful. Feel free to explore other options. • String.contains • String.toLowerCase() or String.toUpperCase String.split StringBuilder.append
Expert Answer:
Answer rating: 100% (QA)
Heres the implementation of the BookFinder class according to the given requirements import javaioBufferedReader import javaioFileReader import javaio... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
In the 1D Arrays Unit, you created a command-line Contact Manager v1. Now upgrade the software to include a graphic user interface. Your contact manager must: Have a menu bar that provides access to...
-
1. Find the general indefinite integral (x +x)dx 2. Find the general indefinite integral (u +4)(2u +1)du 7/4 1+cos? 0 de cos 0 3. Evaluate the integral . 4. Evaluate the integral by making the given...
-
On September 18, 2003, hurricane Isabel struck the North Carolina Coast, causing extensive damage. For several days prior to reaching land the National Hurricane Center had been predicting the...
-
Show that the function have exactly one zero in the given interval. f(x) = x + 4 +7, (-, 0)
-
Quilts R Us (QRU) is considering investing in a new patterning attachment with the cash flow profile shown in the table below. QRU's MARR is 13.5 percent/year. a. What is this investment's external...
-
Parry Company has accounts receivable of $95,400 at March 31, 2012. An analysis of the accounts shows these amounts. Credit terms are 2/10, n/30. At March 31, 2012, there is a $2,100 credit balance...
-
A manufacturing company reports the following information. Raw materials inventory, ending Raw materials used Current Year $ 169,500 2,160,000 1 Year Ago 2 Years Ago $ 190,500 2,522,000 $ 197,500...
-
Compute the mean and median for the duration of hospitalization for the 25 patients? Table 2.13: Hospital-stay data First WBC Received Duration First Received bacterial Sex 1 = M 2 = F (x 10)...
-
13. At some point in the future there will probably be only electric or alternative energy-powered cars on the road. Where will it come from if economic history is a useful guide? a. Centrally...
-
selling price per widget R10 direct materials per widget R1.50 direct labour per widget R1.80 variable overheads per widget R0.70 Fixed cost R20 000 Expected sales for 2023, 10 000 widget calculate...
-
Amadeus started working for Smart Investments Inc. in April 2019 just after he graduated from GBC. He earned $40,000 for the remaining eight months of 2019 and $60,000 in 2020. Smart Investments...
-
Why is diffraction greatest when the width of the gap is equal to wavelength explain using the Huygens model and please make it high school level?
-
What is the structure of short-term and long-term debt? What are the different sources of debt being used? Briefly describe the cost of debt and the capacity of the Woolworths Group Ltd to service...
-
Write a script which will accept 2 numbers and calculate for their difference (NOTE: difference is the result of subtraction). If the difference is negative, display the message "The difference of...
-
1.Which orders had markup above or equal to the departmental markup plan? 2.Which orders failed to meet the departmental plan? 3.Of the orders that failed to meet the departmental markup plan, which...
-
A parking lot charges $3 for the first hour (or part of an hour) and $2 for each succeeding hour (or part), up to a daily maximum of $10. (a) Sketch a graph of the cost of parking at this lot as a...
-
Assume that compression is not used for audio CDs. How many MB of data must the compact disc contain in order to be able to play two hours of music?
-
Write a program that implements message flow from the top layer to the bottom layer of the 7-layer protocol model. Your program should include a separate protocol function for each layer. Protocol...
-
Consider five wireless stations, A, B, C, D, and E. Station A can communicate with all other stations. B can communicate with A, C and E. C can communicate with A, B and D. D can communicate with A,...
-
A candlestick chart is similar to a bar chart except that the candlestick chart: A. Represents upward movements in price with Xs. B. Also graphically shows the range of the periods highs and lows. C....
-
What considerations might encourage a market analyst to rely more on a top-down or bottom-up forecast of S&P 500 operating earnings?
-
Which of the following advantages listed by Ryan with respect to the earnings-based approach studied by Atkinson is most likely correct? The model A. Can be used for non-U.S. equity markets. B....
Study smarter with the SolutionInn App