Create a new project called ManipulatingStrings in a lab06 folder and create a class in it...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Create a new project called ManipulatingStrings in a lab06 folder and create a class in it called 'String Scrambler'. Step 2: Within StringScrambler class, declare one instance variable type string. Name it 'word' Step 3: Write these four methods in the class: - public String scrambleFirstLast() - public String scrambleSecond Third() - public String scrambleAdjacentTwo(int index) - public String scrambleNotAdjacentTwo(int index) Step 4: Complete the method scrambleFirstLast(): This method will return a string where the first character and the last character of the String word. It shouldNOT modify the word as it is stored in the StringScrambler object. Additionally, if the word is less than 2 characters, the method should return NULL. It should return a string made up of: The last character of word All but the first and last characters of word // Could be empty The first character of word For example, If word="apple" Then the method should return eppla If word = hi Then the method should return ih If word = Q Then the method should return null // not the word null, return a null pointer *There are multiple ways to do this including the usage of: Substring charAt Step 5: Complete the method scrambleSecondThird(): It should return a word where the second and third letters are swapped. The first character of word The third character of word The second character of word The rest of the word // may be empty Just like the last method you implemented, you should return null if there are not enough letters. Step 6: Complete method scrambleAdjacent Two(): This method takes the input int x, where x is the INDEX of the character they want to swap. It swaps with the character at x+1. So if the word was 'hello' and you sent scrambleAdjacentTwo(1). The return would be hlelo Step 7: Complete method scrambleNotAdjacentTwo(): This method takes the input int x, where x is the INDEX of the character they want to swap. It swaps with the character at x+2 // notice the difference So if the word was 'hello' and you sent scrambleAdjacentTwo(2). The return would be heoll Create a new project called ManipulatingStrings in a lab06 folder and create a class in it called 'String Scrambler'. Step 2: Within StringScrambler class, declare one instance variable type string. Name it 'word' Step 3: Write these four methods in the class: - public String scrambleFirstLast() - public String scrambleSecond Third() - public String scrambleAdjacentTwo(int index) - public String scrambleNotAdjacentTwo(int index) Step 4: Complete the method scrambleFirstLast(): This method will return a string where the first character and the last character of the String word. It shouldNOT modify the word as it is stored in the StringScrambler object. Additionally, if the word is less than 2 characters, the method should return NULL. It should return a string made up of: The last character of word All but the first and last characters of word // Could be empty The first character of word For example, If word="apple" Then the method should return eppla If word = hi Then the method should return ih If word = Q Then the method should return null // not the word null, return a null pointer *There are multiple ways to do this including the usage of: Substring charAt Step 5: Complete the method scrambleSecondThird(): It should return a word where the second and third letters are swapped. The first character of word The third character of word The second character of word The rest of the word // may be empty Just like the last method you implemented, you should return null if there are not enough letters. Step 6: Complete method scrambleAdjacent Two(): This method takes the input int x, where x is the INDEX of the character they want to swap. It swaps with the character at x+1. So if the word was 'hello' and you sent scrambleAdjacentTwo(1). The return would be hlelo Step 7: Complete method scrambleNotAdjacentTwo(): This method takes the input int x, where x is the INDEX of the character they want to swap. It swaps with the character at x+2 // notice the difference So if the word was 'hello' and you sent scrambleAdjacentTwo(2). The return would be heoll
Expert Answer:
Answer rating: 100% (QA)
Below is the Java code for the specified requirements java public class StringScrambler private Stri... View the full answer
Related Book For
Microsoft Visual C# An Introduction to Object-Oriented Programming
ISBN: 978-1337102100
7th edition
Authors: Joyce Farrell
Posted Date:
Students also viewed these programming questions
-
Design a Java class that represents a cache with a fixed size. It should support operations like add, retrieve, and remove, and it should evict the least recently used item when it reaches capacity.
-
Smart Sets manufactures headphone cases. During September 2016, the company produced 108,000 cases and recorded the following cost data: Requirements 1. Compute the cost and efficiency variances for...
-
What are the bid-ask quotes for: (a) gbp/czj? (b) gbp/dkk? (c) gbp/eur? (d) gbp/nok? The following spot rates against the gbp are taken from the Financial Times of Friday, February 2, 2007. ode...
-
The number of bacteria in a culture is increasing according to the law of exponential growth. There are 125 bacteria in the culture after 2 hours and 350 bacteria after 4 hours. (a) Find the initial...
-
From 2008 to 2015, auto loan rates in the United States declined from around 8% to near historic lows of around 4%. At the same time, auto sales increased dramatically. How, if at all, does this...
-
On January 13, 2013, Precision Oil Company purchased a drilling truck for $90,000. Precision expects the truck to last five years or 200,000 miles, with an estimated residual value of $15,000 at the...
-
You are the Director of the 6 ICU units at your facility. You have an all RN staff and CNA's in each of the units. Your CNO has recently informed you that he has performed a supply audit and has...
-
Complete the statement of cash flow for January through June on the CashFlow worksheet by completing the following tasks. As part of the process, you will need to use a circular reference. You will...
-
Which of the following is (are) true? I) A consequence of unbiased expectations hypothesis is that investors investing over a 6-year period are indifferent between holding a 6-year bond or a 10-year...
-
On December 31st 2023 the City of Mordor leased a piece of equipment from the Gandoff Company for 5 years agreeing to make annual payment of $40,000 beginning December 31, 2023 At the end of the...
-
Blue Ice Limited has $10B in assets and its tax rate is 25%. The firm's Basic Earning Power ratio is 18% and its return on assets (ROA) 12%. What is Blue Ice Limited TIE ratio?
-
Discuss why subsurface colonies on the loop dilution method pour plates showed varying shape versus surface colonies.
-
4. What role do stars play in the film industry? How has that evolved over time? How are stars generally recruited and compensated?
-
You return from a business trip and need to add receipts to your expense report. You should have a receipt for each event. You have the following receipts: Round-trip flight Rental car Conference...
-
You are considering building a dialysis center for Inwood Hospital, and are trying to estimate costs. All of your employees work 2,000 hours per year. You have calculated that each patient visit...
-
The relationship described in question 7 does not always appear to hold. What factors, besides the number of firms in the market, might affect margins?
-
Write an assignment statement that updates a counter variable named quantity by 5.
-
Juan wants a program that calculates and displays the number of miles per gallon he drove his car on a recent trip. When he started the trip, the cars gas tank was full and its odometer read 5500....
-
Follow the instructions for starting C++ and viewing the Advanced27.cpp file, which is contained in either the Cpp8\Chap11\Advanced27 Project folder or the Cpp8\Chap11 folder. (Depending on your C++...
-
How is the legal infrastructure of a country significant for business?
-
What is legal liability?
-
We have a parliament to pass laws, a government to administer laws, and a police department to enforce laws. Ironically, these potent instruments for the restriction of liberty are necessary for the...
Study smarter with the SolutionInn App