Get Writing Help
WhatsApp
    Skip to content
Start Your Order
Uncategorized

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

2 min read

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
Academic Writer & Editor
Limited Offer     Get 25% off your first order — use code STUDYLINK25 at checkout    Claim Now