Question 1

Write a program that declares and initialises an array of strings. Sort the array of strings by increasing length of the string with shortest length first, longest length last. Display the array to the screen before and after sorting to illustrate the sort works.

Hint: Use a class to hold the strings and supply a comparator method.

Question 2

a) Using recursion, compute the sum of all numeric values of each character in a string that are in the range a-z, where a=1, b=2, ... z=26. Any other character has no value. The method is case-sensitive, so uppercase letters have no value. Call the recursive method from main().

b) Now add a class called StringConverter in its own .java file, which has a recursive static method like the one just created but has an extra parameter called caseSensitive which if set to false will treat uppercase letters as lowercase letters. Call this new recursive method statically from main(). For example if this is called on the string abCde with caseSensitive set to false, it will return 15. With caseSensitive set to true it will return 12.

Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.