subject

Write a method printRange (must be solve using recursion) that accepts integer parameters x and y and that prints the sequential integers between x and y inclusive. The first half should be printed with the greater-than character (">") separating consecutive values. The second half should be printed with the less-than character ("<") separating consecutive values. The following table shows several calls and their expected output:

Call Output

printRange(1, 9); 1 > 2 > 3 > 4 > 5 < 6 < 7 < 8 < 9

printRange(10, 20); 10 > 11 > 12 > 13 > 14 > 15 < 16 < 17 < 18 < 19 < 20

printRange(-8, -8); -8

printRange(1, 10); 1 > 2 > 3 > 4 > 5 - 6 < 7 < 8 < 9 < 10

printRange(13, 14); 13 - 14

Notice that in the first output, 5 is in the middle with the numbers before it separated by greater-than and the numbers after it separated by less-than. In the second output, 15 is in the middle with numbers before it separated by greater-than and numbers after it separated by less-than. The third output has no separators because that range includes one number. When there are two values in the middle of the range, those two values should be separated by a dash, as shown in the last two outputs.

The method should throw an IllegalArgumentException if x is greater than y.

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 22:50
An environmental protection agency study of 12 automobiles revealed a correlation of 0.47 between engine size and emissions. at 0.01 significance level, can we conclude that there is a positive association between the variables? what is the p value? interpret.
Answers: 2
question
Computers and Technology, 24.06.2019 06:30
Ineed to know the anwser to all these questions
Answers: 2
question
Computers and Technology, 25.06.2019 06:00
If an image has only 4 colors, how many bits are necessary to represent one pixel’s color?
Answers: 1
question
Computers and Technology, 25.06.2019 12:00
The print command in the powerpoint is found in the? file tab home tab design tab review tab
Answers: 1
You know the right answer?
Write a method printRange (must be solve using recursion) that accepts integer parameters x and y an...
Questions
question
Mathematics, 28.05.2020 23:58
question
Mathematics, 28.05.2020 23:58
question
Physics, 28.05.2020 23:58
Questions on the website: 13722360