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...
-
The map of the world below shows the fraction of the world's surface land area taken up by each continent. In other words, the continent of Africa, for example, makes up 20/100 of the land in the...
-
Perry Shoes Corporation produces three brands of shoes: Brisk, Pro, and Runner. Relevant information about Perry overhead activities, their respective costs, and their cost drivers follows. Required...
-
Each term in the equation of motion of a linear system involves displacement, velocity, and acceleration of the a. first degree b. second degree c. zero degree
-
Cranergy Products is a cranberry cooperative that operates two divisions, a harvesting division and a processing division. Currently, all of harvestings output is converted into cranberry juice by...
-
1. How does the Bail system affect Minority? 2. How does the Bail System violate our constitutional rights? 3. How does the Bail System violate our 8 th and 14 th Amendments? 4. How is the Bail...
-
The data in Table 6E.3 represent the results of inspecting all units of a personal computer produced for the past 10 days. Does the process appear to be in control? Inspected Nonconforming Fraction...
-
Frederick Mining Company owns a large parcel of land which costs $1,050,000. It is estimated to contain 1,800,000 tons of recoverable ore. It is estimated that the recovery of the ore will take 10...
-
Adam, Stanley, and Rosalind formed a partnership in State X to distribute beer and wine. Their agreement provided that the partnership would continue until December 31, 2019. Which of the following...
-
International Distributing Export Company (IDE) was organized as a corporation on September 7, 2009, under the laws of New York and commenced business on November 1, 2009. IDE formerly had existed as...
-
Abbott placed into service a flexible manufacturing cell costing \($850,000\) early this year. They financed \($425,000\) of it at 11 percent per year over 5 years. Gross income due to the cell is...
-
In October 2011, Black, the owner of the Grand Opera House, and Harvey entered into a written agreement to lease the opera house to Harvey for five years at a rental of \($300,000\) a year. Harvey...
-
AgriGrow is to purchase a tractor for over-the-road hauling for \($90,000.\) It is expected to be of use to the company for 6 years, after which it will be salvaged for \($4,000.\) Transportation...
-
A hydroelectric station has to operate with a mean head of 50 m. It makes use of water collected over a catchment area of 200 km over which the average annual rainfall is 420 cm with a 30% loss due...
-
KD Insurance Company specializes in term life insurance contracts. Cash collection experience shows that 20 percent of billed premiums are collected in the month before they are due, 60 percent are...
-
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...
-
Use a process simulator to determine the flow rate of saturated vapor benzene at \(176.2^{\circ} \mathrm{F}\) and \(1 \mathrm{~atm}\) to be mixed with \(100 \mathrm{lbmol} / \mathrm{hr}\) of liquid...
-
Consider the simulation flowsheets in Figure 7.36, which were prepared for ASPEN PLUS. The feed stream, S1, is specified, as are the parameters for each process unit. Complete the simulation...
-
Hot gases from the toluene hydrodealkylation reactor are cooled and separated as shown in the flowsheet of Figure 7.37. In a steady-state simulation, can the composition of the recycle stream be...
Study smarter with the SolutionInn App