Write a main method that reads in a single string and calls


PART A: TEXT TRIANGLE

Write a method that uses recursion to print an input string in the shape of a triangle, where the legs of the triangle are the first and last letters of the string and the base is the complete string; the contents are made up of the letters in between.

For example, given the string "abcdefghij", the corresponding text triangle looks like this:

    aj
   abij
  abchij
 abcdghij
abcdefghij

If there are an odd number of letters in the string, the first line will only have one character (use the first letter); "abcdefghi" generates:
     a
    abi
   abchi
  abcdghi
 abcdefghi

You should write a method called trianglePrint (Strings) that uses recursion to print s as a text triangle. Note that this method does not have enough parameters to do the job, it will need to call another method to solve the problem recursively.

Since your answer is recursive, there should be no loops anywhere in your program. You may want to write more than one recursive method (the triangle printer, and a helper method).

Write a main method that reads in a single string and calls trianglePrint with that string.

Hand in your Java source code, and the output generated (text triangles) for the following two strings (without the quotes): "disestablishmentarianism" and "+- ! '# =-= #* ! -+" (note the five spaces in the second one).

PART B: ORDER UP, THE LAST TIME

Once you've done part A, do it again, except replace the Ar rayLi st with your own linked list implementation. Do it any way you like, as long as the data gets stored in a linked list and stays there (that is, you're not allowed to copy it to or from an array or array list, for sorting or any other purposes).

Solution Preview :

Prepared by a verified Expert
JAVA Programming: Write a main method that reads in a single string and calls
Reference No:- TGS01179441

Now Priced at $40 (50% Discount)

Recommended (99%)

Rated (4.3/5)

A

Anonymous user

4/11/2016 3:23:05 AM

Need to prepare this part of assignment that is about to text triangle Get ready a technique that utilizes recursion to print an input string in the shape of a triangle, where the legs of the triangle are the 1st and last letters of the string and the base is the complete string; the contents are made up of the letters in between. For instance, specified the string "abcdefghij", the equivalent text triangle looks like this: You must prepare a technique said triangle Print (Strings) that utilizes recursion to print s as a text triangle. Given memo that this method doesn’t have sufficient parameters to do the job; it will need to call another process to answer the issue recursively.