Write a database manager that can store and work with a table of strings. It could...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a "database manager" that can store and work with a table of strings. It could be used to store a class list. Your program should consist of two classes: Database class. This class should store the array (table) as a field and provide the following methods: " " " Database(int size) - A one-argument constructor which accepts the size of the table (array). It should use this size to allocate (create) the array add(int index, String value) - Set the value of the array entry at the specified index. print() - Print the contents of the array sort() - Sort the contents of the array in ascending numerical order (Hint: use the Arrays class) find(String value) - Search for a particular string in the array. If it is found print out "Entry found", otherwise print out "Not found". The Database class should not have a main() method (cont'd next page) Review Ex 12: Simple Database (cont'd) DatabaseTester class. This class uses and tests your Database class. It should contain just a main method which does the following: 1. Create a Database object of size 10. Instead of the actual number 10 you should use a constant (final) field. 2. Prompt the user to enter strings (lines of text) to add to the table. Input 10 strings and add them using the 'add' method of the Database class. 3. Print out the resulting table using the Database 'print' method. 4. Sort the database by calling the the 'sort' method. 5. Print the table again to show the sorted strings. 6. Display whether the database contains your name using the 'find' method. Don't use static' except for the main() method declaration and final fields Write a "database manager" that can store and work with a table of strings. It could be used to store a class list. Your program should consist of two classes: Database class. This class should store the array (table) as a field and provide the following methods: " " " Database(int size) - A one-argument constructor which accepts the size of the table (array). It should use this size to allocate (create) the array add(int index, String value) - Set the value of the array entry at the specified index. print() - Print the contents of the array sort() - Sort the contents of the array in ascending numerical order (Hint: use the Arrays class) find(String value) - Search for a particular string in the array. If it is found print out "Entry found", otherwise print out "Not found". The Database class should not have a main() method (cont'd next page) Review Ex 12: Simple Database (cont'd) DatabaseTester class. This class uses and tests your Database class. It should contain just a main method which does the following: 1. Create a Database object of size 10. Instead of the actual number 10 you should use a constant (final) field. 2. Prompt the user to enter strings (lines of text) to add to the table. Input 10 strings and add them using the 'add' method of the Database class. 3. Print out the resulting table using the Database 'print' method. 4. Sort the database by calling the the 'sort' method. 5. Print the table again to show the sorted strings. 6. Display whether the database contains your name using the 'find' method. Don't use static' except for the main() method declaration and final fields
Expert Answer:
Related Book For
Understanding Business Ethics
ISBN: 9781506303239
3rd Edition
Authors: Peter A. Stanwick, Sarah D. Stanwick
Posted Date:
Students also viewed these programming questions
-
Q1. You have identified a market opportunity for home media players that would cater for older members of the population. Many older people have difficulty in understanding the operating principles...
-
answer the question clearly You are building a flight-control system for which a convincing safety case must be made. Would you assign the tasks of safety requirements engineering, test case...
-
Suppose you are given the following set of data with three Boolean input variables a, b, and c, and a single Boolean output variable K. a bc K 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 01 For parts (a) and (b),...
-
Ammonium nitrate dissolves spontaneously and endothermally in water at room temperature. What can you deduce about the sign of S for this solution process?
-
17. A concave mirror produces a real image 10mm tall, of an object 2.5mm tall placed at 5cm from the mirror. Calculate focal length of the mirror and the position of the image. 18. An object is...
-
Give an explicit solution for the mean-reverting rnstein-Uhlenbeck SDE \[d X_{t}=\alpha\left(\mu-X_{t} ight) d t+\sigma d B_{t}\] with \(X_{0}=x\).
-
On January 1, 2010, Furball Company had Accounts Receivable $98,000 and Allowance for Doubtful Accounts $8,100. Furball Company prepares financial statements annually. During the year the following...
-
Consider a two-period binomial model in which a stock currently trades at a price of$70. The stock price can go up 15% or down 15% each period. The risk-free rate is 5%.Calculate the price of a...
-
(3.19) 72,500 lb/h of crude oil are to be heated from 250F to 320F by cooling a lube oil from 450F to 340F. Physical properties of the two streams may be assumed constant at the following values:...
-
If the reserve ratio is and the central bank increases the quantity of reserves in the banking system by $120, the money supply increases by a. $90. b. $150. c. $160. d. $480.
-
Recessions occur a. regularly, about every 3 years. b. regularly, about every 7 years. c. regularly, about every 12 years. d. irregularly.
-
Because most loans are written in ________ terms, an unexpected increase in inflation hurts ________. a. real; creditors b. real; debtors c. nominal; creditors d. nominal; debtors
-
In the United States, unionized workers are paid about _____ percent more than similar nonunion workers. a. 2 b. 5 c. 15 d. 40
-
What are the capabilities needed to be a broad adaptive cost leader?
-
The owners of Crackers, Inc. produces both Deluxe (D) and Classic (C) crackers. She only has 4,800 ounces of sugar, 9,600 ounces of flour, and 2,000 ounces of salt for her next production run. A box...
-
Below is a sample of the data in the file NFLAttendance which contains the 32 teams in the National Football League, their conference affiliation, their division, and their average home attendance....
-
Organization is viewed as a/an ________ process and a management activity, which is crucial for predicting the consumption of a companys resources. Active Passive Intermediary None of the above
-
A narrow span of control does not aid better communication between the superior and the subordinates. True False
-
The ________ networks are usually temporary in nature. Line-and-staff organization Network organizational Virtual organization Tall organizational
Study smarter with the SolutionInn App