Lab #8

Use this link for the String API (useful methods for this lab).
Methods you might need to use in this lab are: substring, contains, indexOf, replace, replaceAll
  1. Create two String variables. Assing "The best class ever,,," to the first String, and "and the best dxy ever" to the second string. Use different assignment methods for two strings:
    String a = ""; and String b = new String("");
  2. Concatenate the two strings to each other and assign the resultant string to a new variable called d.
  3. Print the concatenated string.
  4. Replace ",,," with ", ".
  5. Replace "dxy" with "day".
  6. Add a period to the end of the sentence and print it.
  7. Ask the user to enter a word and check if the string contains that word. Print "The string contains your word!" if the string contains it, and "The string does not contain your word!" otherwise.
  8. Capitalize the first character of the second word of the sentence and print the revised sentence.
  9. Remove every 'r' character from the sentence and print the sentence.
Home exercises:
  1. See this link for sample programs on basics of Java Strings.
  2. Repeat step #8 for third word of the sentence.
  3. Repeat step #8 for last word of the sentence .
  4. Repeat step #4 without using replace method. You can use indexOf(",,,") and substring method instead.
  5. Repeat step #5 without using replace method. You can use indexOf(",,,") and substring method instead.
  6. Receive two words from the user and print which one is occured sooner than the other one in the sentence.