Create a class named Yourlastname_Yourfirstname_hw4. (10 pts) 1. Add a method named problem1 that keeps asking...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Create a class named Yourlastname_Yourfirstname_hw4. (10 pts) 1. Add a method named problem1 that keeps asking the user for words and joins them together. Each word should start with an uppercase letter and the rest of letters in the word should be lowercase. All the words should be separated by a space. When the user decides to stop, return the joined string. (10 pts) 2. Add a method named problem2 that asks the user for a string. Count and return the frequency of letter A. The letters are not case-sensitive, so for example, you should treat "A" and "a" as the same letter. (10 pts) 3. Add a method named problem3 that accepts a string and reverses it by manipulating indices. (10 pts) 4. Add a method named problem4 to remove the 10-th index character from the given string and return the result. If 10 is an invalid index, return an error message. (10 pts) 5. Add a method named problem5 that accepts an adjective, forms an adverb from the adjective, and returns the adverb. " In most cases, an adverb is formed by adding -ly to an adjective. For example, quick → quickly If the adjective ends in -y, replace the y with i and add -ly. For example, easy → easily If the adjective ends in -able, -ible, or -le, replace the -e with -y. For example, gentle → gently If the adjective ends in -ic, add -ally. For example, basic → basically. (10 pts) import java.util.Arrays Only the Arrays class is allowed to solve the following problems: 6. Add a method named problem6 that accepts an array of integer values. Find and remove all the duplicate values. Return the result. Test case: the given integer array is {2, 3, 1, 4, 1, 2, 4, 2, 1, 4, 2, 3}, return {2, 3, 14} 7. Add a method named problem 7 that accepts an array of String values. Find and remove all the duplicate string literals. The string literals are not case-sensitive, so for example, you should treat "apple" and "APPLE" as the same string. Return the result. Test case: the given string array is {"apple", "Apple", "banana", "APPLE"}, return {"apple", "banana"} 8. Add a method named problem8 that accepts two arrays of string values. Find and common elements. You may assume each array contains unique elements. Return the result. Test case: array1 is {"banana", "apple", "orange"}, array2 is {"apple", "strawberry", "watermelon", "banana"}, return {"banana", "apple"}. 9. Add a method named problem9 that accepts two arrays of integer values. Find the elements that only appear in one of the arrays. You may assume each array contains unique elements. Return the result. Test case: array1 is {1, 4, 3, 2, 5}, array2 is {7, 5, 4, 6}, return {1, 3, 2, 7, 6}. Page | 1 10. Add a method named problem 10 that accepts an array of integers. Move all O's to the end of an array if any. Give two references, start and end, to initially point at the first and last elements in the array. Swap the elements at start and end if necessary. Make them gradually meet in the middle. Return the result. Test case: array1 is {2, 0, 0, 1, 3, 1, 3, 0, 2, 0}, return {2, 2, 3, 1, 3, 1, 0, 0, 0, 0}. Create the main method and run each method with the test case. Submit your Yourlastname_Yourfirstname_hw4.java file on blackboard. Page | 2 Create a class named Yourlastname_Yourfirstname_hw4. (10 pts) 1. Add a method named problem1 that keeps asking the user for words and joins them together. Each word should start with an uppercase letter and the rest of letters in the word should be lowercase. All the words should be separated by a space. When the user decides to stop, return the joined string. (10 pts) 2. Add a method named problem2 that asks the user for a string. Count and return the frequency of letter A. The letters are not case-sensitive, so for example, you should treat "A" and "a" as the same letter. (10 pts) 3. Add a method named problem3 that accepts a string and reverses it by manipulating indices. (10 pts) 4. Add a method named problem4 to remove the 10-th index character from the given string and return the result. If 10 is an invalid index, return an error message. (10 pts) 5. Add a method named problem5 that accepts an adjective, forms an adverb from the adjective, and returns the adverb. " In most cases, an adverb is formed by adding -ly to an adjective. For example, quick → quickly If the adjective ends in -y, replace the y with i and add -ly. For example, easy → easily If the adjective ends in -able, -ible, or -le, replace the -e with -y. For example, gentle → gently If the adjective ends in -ic, add -ally. For example, basic → basically. (10 pts) import java.util.Arrays Only the Arrays class is allowed to solve the following problems: 6. Add a method named problem6 that accepts an array of integer values. Find and remove all the duplicate values. Return the result. Test case: the given integer array is {2, 3, 1, 4, 1, 2, 4, 2, 1, 4, 2, 3}, return {2, 3, 14} 7. Add a method named problem 7 that accepts an array of String values. Find and remove all the duplicate string literals. The string literals are not case-sensitive, so for example, you should treat "apple" and "APPLE" as the same string. Return the result. Test case: the given string array is {"apple", "Apple", "banana", "APPLE"}, return {"apple", "banana"} 8. Add a method named problem8 that accepts two arrays of string values. Find and common elements. You may assume each array contains unique elements. Return the result. Test case: array1 is {"banana", "apple", "orange"}, array2 is {"apple", "strawberry", "watermelon", "banana"}, return {"banana", "apple"}. 9. Add a method named problem9 that accepts two arrays of integer values. Find the elements that only appear in one of the arrays. You may assume each array contains unique elements. Return the result. Test case: array1 is {1, 4, 3, 2, 5}, array2 is {7, 5, 4, 6}, return {1, 3, 2, 7, 6}. Page | 1 10. Add a method named problem 10 that accepts an array of integers. Move all O's to the end of an array if any. Give two references, start and end, to initially point at the first and last elements in the array. Swap the elements at start and end if necessary. Make them gradually meet in the middle. Return the result. Test case: array1 is {2, 0, 0, 1, 3, 1, 3, 0, 2, 0}, return {2, 2, 3, 1, 3, 1, 0, 0, 0, 0}. Create the main method and run each method with the test case. Submit your Yourlastname_Yourfirstname_hw4.java file on blackboard. Page | 2
Expert Answer:
Answer rating: 100% (QA)
Heres a Java class named YourlastnameYourfirstnamehw4 with all the required methods implemented import javautilArrays public class YourlastnameYourfir... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Choose a topic that can be applied to one of the following economic concepts. (Possible curves: Lorenz curve, marginal product of labor curve, labor demand and supply curves, utility function and...
-
Suppose that the owner of the restaurant in Problem 2.91 also wants to study the demand for dessert during the same time period. She decides that in addition to studying whether a dessert was...
-
Mary and Sally are in a foot race (Fig. 2-39). When Mary is 22 m from the finish line, she has a speed of 4.0 m / s and is 5.0 m. behind Sally, who has a speed of 5.0 m / s. Sally thinks she has an...
-
Which of the following is an investing activity? a. Issuance of a mortgage b. Purchase of land c. Increase in accounts receivable d. Increase in inventories e. All of the above
-
The John Gore Organization owns and operates the Charles Playhouse, a theater in Boston, Massachusetts. Evelyn Castillo has diabetes, a disability under the Americans with Disabilities Act (ADA)....
-
The City of Faireld issued $100 million of 20-year, 6 percent coupon bonds (3 percent per semiannual period) for $89.32 million. The price reected a yield of 7 percent (3.5 percent period semiannual...
-
Student Name: Anthony Jedruczek (Please PRINT your name) Assume that Q-Caf has the following transactions related to the sale of coffee beans during the month of October, 2023. Oct 1 Oct 5 Oct 15 Oct...
-
What Happens When You Dont Deliver on Your Promises Web: www.clearly.ca Facebook: Clearly Canadian If a new product or service seems like the perfect option to solve a problem or capitalize on an...
-
How would you describe Workforce Diversity? Why is it important for managers to have an understanding of diversity?
-
In January the company produced 3,340 units using 2,792 direct labour-hours. During the month, the actual direct labor cost was $63,813. Direct labour 0.8 The labour rate variance for January is?
-
A home-based sign company uses this function to model its monthly profit, where x is the price of each sign it sells. p(x)=-10x^(2)+498x-1,500 What is the company's profit if it sells each sign for...
-
2 8 . Last week, Miss Bannerman asked her stockbroker to immediately buy 5 , 0 0 0 shares of the equity stock of Ponzo Illusions at the ruling market price for her. The broker was able to acquire all...
-
1. What is the purpose of dependent and independent variables in forecasting and what is the relationship? How does correlation factor into the relationship between variables? GIve an example of an...
-
Insert a button type object in your excel sheet and using the VBA editor to program the following code Run the code and say what is the result obtained if first number is 23 and second number is 4....
-
1. SPAC ONE aims to raise $250 million to merge in the next 24 months with a private firm selected among potential prospects in the health care space. The bank supporting the SPAC in its capital...
-
The diagram shows the two forces acting on a small object. Which of the following is the resultant force on the object? A. 8 N downwards B. 8 N upwards C. 2 N downwards D. 2 N upwards 3 N 5 N
-
An English-like programming language such as Java or Visual Basic is a ________ programming language. a. Machine-level b. Low-level c. High-level d. Binary-level
-
Every module has all of the following except___________ . a. A header b. Local variables c. A body d. A return statement
-
Each of the programs in Figure 9-25 uses a recursive method. Try to determine the output in each case. a. b. c. start start start output recursiveA(0) stop num recursiveA(num x) num result if x = 0...
-
In Theorem 1.15 prove that \(E_{p}(x, \delta)=o\left(\delta^{p}ight)\), as \(\delta ightarrow 0\). Theorem 1.15. Let f be a function that has p+ 1 bounded and continuous derivatives in the interval...
-
Prove Part 3 of Theorem 1.14 using only Definition 1.6. That is, prove that for any non-negative integer \(k\), \[\frac{d}{d x} H_{k}(x)=k H_{k-1}(x)\] Do not use the result of Part 1 of Theorem...
-
Consider approximating the normal tail integral \[\bar{\Phi}(z)=\int_{z}^{\infty} \phi(t) d t\] for large values of \(z\) using integration by parts as discussed in Example 1.24. Use repeated...
Study smarter with the SolutionInn App