Write a Java program that creates a string array by getting the capacity and elements from...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a Java program that creates a string array by getting the capacity and elements from the user. After creating the array, read another string from the user and search it through the array. If that string exists in the array, print the element number of that string. If no match is found, display "Word not found in the array" message. Sample Output: Enter the capacity of the array: Enter the element 1 of the array: ted Enter the element 2 of the array: university Enter the element 3 of the array: computer Enter the element 4 of the array: engineering Enter the word to be searched in the array: computer Word computer is found in the array and it is element 3! Enter the capacity of the array: 3 Enter the element 1 of the array: java Enter the element 2 of the array: array Enter the element 3 of the array: lab Enter the word to be searched in the array: ted Word not found in the array. Write a Java program that creates a string array by getting the capacity and elements from the user. After creating the array, read another string from the user and search it through the array. If that string exists in the array, print the element number of that string. If no match is found, display "Word not found in the array" message. Sample Output: Enter the capacity of the array: Enter the element 1 of the array: ted Enter the element 2 of the array: university Enter the element 3 of the array: computer Enter the element 4 of the array: engineering Enter the word to be searched in the array: computer Word computer is found in the array and it is element 3! Enter the capacity of the array: 3 Enter the element 1 of the array: java Enter the element 2 of the array: array Enter the element 3 of the array: lab Enter the word to be searched in the array: ted Word not found in the array.
Expert Answer:
Answer rating: 100% (QA)
Heres a Java program that creates a string array based on user input and then searches for a specifi... View the full answer
Related Book For
Introduction to Algorithms
ISBN: 978-0262033848
3rd edition
Authors: Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest
Posted Date:
Students also viewed these programming questions
-
Water usage varies greatly in different countries, from as little as 20 liters a day per capita (per person) in some third-world countries, to several hundred liters a day in some industrialized...
-
You have now been asked to work with a textile startup business that your firm has just taken on as a client. The business is particularly in need of support and guidance with budgeting and how it...
-
You must decide whether to buy, build or lease a building for your business needs over the next 10 years. If you decide to build, you must determine if it is better to buy an existing building and...
-
Data from the registrar's office at Gigantic State University indicate that over the past 20 years tuition and enrollment have both increased. From this information we can conclude that: A. higher...
-
An old car with worn-out shock absorbers oscillates with a given frequency when it hits a speed bump. If the driver adds a couple of passengers to the car and hits another speed bump, (a) Is the...
-
Talladega Tire and Rubber Company has capacity to produce 500,000 tires. Talladega presently produces and sells 400,000 tires for the North American market at a price of $200 per tire. Talladega is...
-
Theoretically, a control procedure should only be implemented if the benefits it provides exceed its costs. How can you estimate the costs and benefits of the following controls: a. segregation of...
-
The University of Michigan football stadium, built in 1927, is the largest college stadium in America, with a seating capacity of 114,000 fans. Assume the stadium sells out all six home games before...
-
Tailwind, Inc., produces high - quality but inexpensive training shoes for runners. The Tailwind shoe, which sells for $ 2 1 0 , contains both gas - and liquid - filled compartments to provide more...
-
In April 2005, the SEC announced settlement with Coca- Cola Company of charges of fraud and false and misleading financial reporting. The charges arose from gallon push-ing at Coca- Colas Japanese...
-
3. Assume X1,..., Xn ~i.i.d. N (, ), where both the mean and variance are unknown. Consider a general estimator for 2 defined by n a (Xi - X), i=1 (1) where a is a given real number; two specific...
-
How may overly strict government regulation of environmental hazards be self-defeating? Can you think of any specific examples of laws intended to benefit public health that may do more harm than...
-
Prepare the necessary journal entries from the following information for Brady Company, which uses a perpetual inventory system. a. Purchased raw material on account, $56,700. b. Requisitioned raw...
-
Create a program that demonstrates how to create class files and objects using object-oriented programming. Think of this as a first step in creating a game and consider the user's interaction with...
-
How much will the investor have today if he has a simple annuity of $80,000 deposited in an account earning an interest rate of 5% for a perpetual period of time?
-
A single-span highway vehicular bridge will cross a small ravine. The bridge is of a deck- girder type and is of composite steel-concrete construction. Abut. no. 1 4 Bridge Expansion bearing 28-12 x...
-
Allocation of Support Departments Western Sales, Eastern Sales, and International Sales are profit centers for XYZ Company. Human Resources, Information Systems, and Maintenance are support...
-
Carlton Stokes owns and operates a car-detailing business named SuperShine & Detailing. For $150, Carltons business will hand wash and wax customers cars, vacuum the interior, and thoroughly clean...
-
What is the largest k such that if you can multiply 3 3 matrices using k multiplications (not assuming commutativity of multiplication), then you can multiply n n matrices in time o(n lg 7 )? What...
-
One class of permutations of the integers in the set S n = {0, 1, 2, . . . , 2 n 1} is defined by matrix multiplication over GF (2). For each integer x in S n , we view its binary representation as...
-
Professor Borden proposes a new divide-and-conquer algorithm for computing minimum spanning trees, which goes as follows. Given a graph G = (V, E), partition the set V of vertices into two sets V 1...
-
Public choice economists believe that the behavior of individuals in politics, as in the marketplace, will be influenced by _________.
-
In private markets, an individual _________ link indicates that the goods consumers get reflect what they are willing to pay for.
-
Even though actors in both the private and public sectors are _________, the _________ are different.
Study smarter with the SolutionInn App