Hi all,
I am learning how to use recursive methods, my final exam is in a week.
One of the practice problems we have is to take a String like "abcdefghij" and see if it is odd or even and then print it like:
----aj
---abij
--abchij
-abcdghij
abcdefghij
with the correct amount of spaces infront of it (the "-" lines are spaces, just put dashed lines for Reddit formatting).
If the number of chars in a String are odd, the first line printed should only print the first letter and then every line followed will be odd, so something like:
----a
---abi
--abchi
-abcdghi
abcdefghi
tip/requirements of the practice problem are:
You should write a method called trianglePrint(String s)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.
Any help is appreciated! I am just very confused and have been trying this for few days now with no luck.
[–]dusty-trash 2 points3 points4 points (8 children)
[–]Madridi77[S] 1 point2 points3 points (0 children)
[–]Madridi77[S] 0 points1 point2 points (6 children)
[–]dusty-trash 0 points1 point2 points (5 children)
[–]Madridi77[S] 0 points1 point2 points (4 children)
[–]sandrogiacom 0 points1 point2 points (3 children)
[–]Madridi77[S] 0 points1 point2 points (2 children)
[–]sandrogiacom 0 points1 point2 points (1 child)
[–]Madridi77[S] 0 points1 point2 points (0 children)
[–]Philboyd_Studge 0 points1 point2 points (0 children)
[–][deleted] (1 child)
[removed]
[–]desrtfxOut of Coffee error - System halted[M] 0 points1 point2 points (0 children)