Write My Paper Button

WhatsApp Widget

10. Recursive Append Download the file AppendRec.java. Write your code inside the appendNTimes method and use…

Homework Help Question & Answers

10. Recursive Append Download the file AppendRec.java. Write your code inside the appendNTimes method and use…

10. Recursive Append Download the file AppendRec.java. Write your code inside the appendNTimes method and use the main method to test your code. Submit the file AppendRec.java. There is no need to delete the main method, the autograder will only grade appendNTimes. The method appendNTimes is recursive and takes two arguments, a string and an integer. It returns the original string appended to the original string n times. The method signature is as follows public static String appendNTimes ( String original, int n ) Examples: appendNTimes( “cat”, 0 ) returns “cat” appendNTimes(“cat”, 1 ) returns “catcat appendNTimes( “cat”, 2 ) returns “catcatcat” Observe the following rules: YOUR CODE MUST BE RECURSIVE Assume n 0
public class AppendRec 1 public static void main (String args) ( System.out.println (appendNTimes(“tea”, 0)) System.out.println(appendNTimes (“t”, 0)) System.out.println (appendNTimes(“tea”, 1)) System.out.println (appendNTimes(“tea”, 4)) public static String appendNTimes (String original, int n)t WRITE YOUR CODE HERE / Method must be recursive!!!
Observe the following rules: YOUR CODE MUST BE RECURSIVE Assume n0 Do not use loops (while, do/while, orfor). Do NOT declare any variables outside of a method. You may declarc DO NOT add any import statements to AppendRec.java DO NOT add the project statement to AppendRecjava DO NOT change the headers of ANY of the given methods DO NOT add any new class fields DO NOT use System.exit) ariables inside a method Note: you have 3 submissions without deductions; 5 points deduction for every submission thereafter
0 0
Add a comment
Don`t copy text!
WeCreativez WhatsApp Support
Our customer support team is here to answer your questions. Ask us anything!
???? Hi, how can I help?