On this lab (and all future work in this course), the name of the files you submit and the name of the classes they contain must match. That is, the file Foo.java must contain (only) the class Foo.
-
Create a class
Trianglethat contains the following functions:-
The function
triangleLoopshould take a string as its argument and print the characters of the string as a “triangle”, adding one character with each line. So, the statementTriangle.triangleLoop("CMPT");should print this:C CM CMP CMPT
This much be done with a loop.
-
The function
triangleRecursiveshould do the same astriangleLoop, but must be written recursively. It should not contain a loop. -
The function
triangleUpLoopshould be similar totriangleLoop, but should print a triangle that grows up, instead of down. So,Triangle.triangleUpLoop("CMPT");should print this:CMPT CMP CM C
This much be done with a loop.
-
The function
triangleUpRecursiveshould do the same astriangleUpLoop, but must be written recursively. It should not contain a loop.
-
The function
-
Create a text file named
time.txt. In it, indicate how long it took you to complete this lab exercise.
When you're done, create a ZIP file containing all of the files you created for this lab and submit it with the submission server.