Question: --------IR17.java public interface IR17 { /* Precondition: n >= 0 (no need to check). Postcondition: returns the nth number in a sequence where each element

--------IR17.java

public interface IR17 {

/* Precondition: n >= 0 (no need to check). Postcondition: returns the nth number in a sequence where each element is twice its predecessor, and starts with 1. */ public int pracSeq1(int n);

/* Precondition: n >= 0 (no need to check). Postcondition: returns the nth number in a sequence where each element is the sum of the previous 3, and starts with 1,2,3 */ public int sequence2(int n);

/* Precondition: n >= 0 (no need to check). Postcondition: returns the nth number in a sequence where each element is twice its predecessor (n-1) plus 3 times its predecessor (n-2) and starts with 1, 2. 7. */ public int sequence3(int n);

}

--------------------- R17.java

public class R17 implements IR17{

public static void main(String[] args) { R17 rec = new R17(); System.out.println("pracSeq1(int x):"); System.out.println("Answer: " + rec.pracSeq1(5) + " Expecting: 32"); System.out.println("Answer: " + rec.pracSeq1(7) + " Expecting: 128 ");

System.out.println("sequence(int x):"); System.out.println("Answer: " + rec.sequence2(4) + " Expecting: 11"); System.out.println("Answer: " + rec.sequence2(5) + " Expecting: 20 ");

System.out.println("sequence3:"); System.out.println("Answer: " + rec.sequence3(2) + " Expecting: 7"); System.out.println("Answer: " + rec.sequence3(3) + " Expecting: 20"); System.out.println("Answer: " + rec.sequence3(6) + " Expecting: 547 ");

}

public int pracSeq1(int n) { if(n == 0) return 1; return 2 * pracSeq1(n - 1);

} public int sequence2(int n) { if(n == 0) return 1; else if (n == 1) return 2; else if(n == 2) return 3; return sequence2(n - 1) + sequence2(n - 2) + sequence2(n - 3); } public int sequence3(int n) { // I need code here return 0; } }

output

pracSeq1(int x): Answer: 32 Expecting: 32 Answer: 128 Expecting: 128

sequence(int x): Answer: 11 Expecting: 11 Answer: 20 Expecting: 20

sequence3: Answer: 0 Expecting: 7 Answer: 0 Expecting: 20 Answer: 0 Expecting: 547

----------

I want output

Answer: 7 Expecting: 7 Answer: 20 Expecting: 20 Answer: 547 Expecting: 547

in sequence 3.

Plz follow the instruction in IR17 to complete.

output I want:

pracSeq1(int x): Answer: 32 Expecting: 32 Answer: 128 Expecting: 128

sequence(int x): Answer: 11 Expecting: 11 Answer: 20 Expecting: 20

sequence3: Answer: 7 Expecting: 7 Answer: 20 Expecting: 20 Answer: 547 Expecting: 547

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!