Question: Create a program, StringRegexLab.java, which will complete the following. 1 st Problem: State to the screen how many constructors there are for the String class.

Create a program, StringRegexLab.java, which will complete the following.

1st Problem:

  1. State to the screen how many constructors there are for the String class.
  2. State to the screen whether the String class is mutable or immutable. If it is immutable, state what is returned each time a method that changes the String is invoked in the String class.
  3. State to the screen the difference between a literal String (interned string) and a String object.
  4. Create a String object with the value CSC 202 and print it to the screen.
  5. Invoke the toString method on the variable from #4, display the returned value to the screen.
  6. Create an interned string/String literal with the value of CSC 202 and print it to the screen.
  7. Invoke the toString method on the variable from #6, display the returned value to the screen.
  8. Create a String array with the value: 102,202,211,214,302,323 using the comma as the split method argument.
  9. Print the array to the screen.

2nd Problem: write an app that eliminates the typing error of having extra white space around a word and the error of inserting an extra space within a word

Procedure: read in a word, utilize a method that removes the extra spaces around the word, then check to see if there are spaces with the word and eliminate those (fyi: \s is the code for a space)

3rd Problem: write an app to shorten text messages that are over 10 characters long. When a message is over 10 characters, following rules will work to shorten the messages:

  1. eliminate vowels, unless a word starts with a vowel
  2. eliminate repeated letters in a word

Show how many character have been eliminated with your app.

Procedure: read in a line of text as one String, convert it to lowercase letters, and check the length; when it is over 10 characters get a character 1 by 1 (you might need an extra variable to help you with this) and

  • ignore the 1st character of a word if it is a vowel
  • if the character is a vowel and not the 1st character, do not use the character and increment the value that is counting the replacements
  • if the character is a repeating character, do not use the character and increment the value that is counting the replacements

Regex Part Input: regexlab.txt

Output: to screen

A valid license plate has the format of three upper case letters or digits, a space, and then four upper case letters or digits. Based on this format, read in a license plate from the file (until there is no more to be read) and then validate or reject the proposed sequence for a license plate. regexlab.txt ABC 1234 HJ3 35OP )(4 POkj 490nnIOK 86R TLM9 tYU 97M QAU IFB pI9 3fX ZI7 D60 L82 HWC tYU 97M QAU IFB pI9 3fX ZI7 D60 L82 HWC

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!