Question: Java, pls use loop and strings Write a public class call StringMethods with a main method. what it does: 0. prompt user for a String
Java, pls use loop and strings Write a public class call StringMethods with a main method. what it does: 0. prompt user for a String - read String 1. prompt user for an int - read integer 2. if integer is 0 end program 3. if String is "0", end program 4. if integer is not between 1 and 10 go back to step 0 5. if integer is between 1 and 10 (inclusive) perform the operation and print the message that matches the examples below. Each number corresponds to a different operation. 6. repeat from step 0
enter a string (end with 0): abcABC123 enter an int (end with 0): 1 upper case: ABCABC123 enter a string (end with 0): abcABC123 enter an int (end with 0): 2 lower case: abcabc123 enter a string (end with 0): abcABC123 enter an int (end with 0): 3 replace all a's by "foo": foobcABC123 enter a string (end with 0): abcABC123 enter an int (end with 0): 4 a b c A B C 1 2 3 enter a string (end with 0): abcABC123 enter an int (end with 0): 5 first: a last: 3 enter a string (end with 0): abcABC123 enter an int (end with 0): 6 it doesn't contain 'z' enter a string (end with 0): abcABC123 enter an int (end with 0): 7 reverse: 321CBAcba enter a string (end with 0): 8 enter an int (end with 0): 8 string is too short enter a string (end with 0): abcABC123 enter an int (end with 0): 8 substring from 3rd character to end: cABC123 enter a string (end with 0): a enter an int (end with 0): 9 string is too short enter a string (end with 0): abcABC123 enter an int (end with 0): 9 substring from 2nd character to 4th (inclusive): bcA enter a string (end with 0): a enter an int (end with 0): 10 'z' does not appear in second half enter a string (end with 0): abcABC1z23 enter an int (end with 0): 10 'z' appears in second half enter a string (end with 0): aazaa enter an int (end with 0): 10 'z' appears in second half enter a string (end with 0): abc enter an int (end with 0): 11 enter a string (end with 0): 0 % java StringMethods enter a string (end with 0): 1234z1234 enter an int (end with 0): 10 'z' appears in second half enter a string (end with 0): 0
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
