Question
Write using Java a recursive method printBracketRanges that takes two integer parameters x and y and returns a String of the the sequential integers between
Write using Java a recursive method printBracketRanges that takes two integer parameters x and y and returns a String of the the sequential integers between x and y inclusive.
The first half should be seperated by ">" while and second half should be seperated by "<".
The following are examples cases
printBracketRanges(2, 8); // should return "2 > 3 > 4 > 5 < 6 < 7 < 8"
printBracketRanges(11, 19); // should return "11 > 12 > 13 > 14 > 15 < 16 < 17 < 18 < 19"
printBracketRanges(-2, -2); // should return "-2"
printBracketRanges(1, 10); // should return "1 > 2 > 3 > 4 > 5 - 6 < 7 < 8 < 9 < 10"
printBracketRanges(15, 16); // should return "15 - 16"
When x is greater than y, the method should throw an IllegalArgumentException.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started