Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

6 . Programming Task 3 For this task, you should implement a recursive function that gets 3 parameters and return a string that is made

6. Programming Task 3
For this task, you should implement a recursive function that gets 3
parameters and return a string that is made of the first two input parameters
repeatedly. This means the output contains the first input followed by the
second input, followed by the first input again, .....The number of repetition of
the input strings is specified by the third argument of the method.
Here are some examples:
interlace(Hello ,World ,0) returns
interlace(Hello ,World ,1) returns Hello
interlace(Hello ,World ,2) returns Hello World
interlace(Hello ,World ,3) returns Hello World Hello
The name of the method is interlace and the header of the method was
written for you in Lab2.java.
7. Programming Task 4
In this task, you are required to write a recursion that gets a string and two
characters and returns the substring that is enclosed in two given characters.
You can assume that the given string includes only one instance of each
enclosing characters.
For example, where the input string is This is [quite} an example! and the first
enclosing character is '[' and the second is '}', it should return quite.
The name of the method is getSubstring and the header of the method was
written for you in Lab2.java.
8. Programming Task 5
For this task, you need to write a recursion that converts a positive integer
including zero, to its binary equivalence. This method gets one integer input.
A binary form of an integer is calculated by repeatedly dividing the integer
number (and later, its quotient) by 2. You keep doing the division until the
quotient is zero. The reminders of the divisions, from the last division to the
first, form the binary representation of the integer number. Lets see an
example in which 23 is converted to a binary number. R stands for the
remainder.
23/2=11 R 1
11/2=5 R 1
5/2=2 R 1
2/2=1 R 0
1/2=0 R 1
Therefore, the binary representation of 23 is 10111.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions