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, 22.06.2019 09:00
Create a cell reference in a formula by typing in the cell name or         a. right-clicking the cell. b. clicking the cell. c. clicking the column where the cell is located. d. clicking the row where the cell is located.
Answers: 1
question
Computers and Technology, 22.06.2019 16:30
What type of file does a cookie place on web site visitors' computers so that web site managers can customize their sites to their visitors' preferences?
Answers: 1
question
Computers and Technology, 23.06.2019 15:30
Hey so i was just trying out some game hacks so i took a paste from online and built it in my visual studio and then suddenly my computer was working or clicking on stuff on its own am i hacked?
Answers: 1
question
Computers and Technology, 23.06.2019 22:30
How many points do i need before i can send a chat
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
English, 07.12.2020 03:30
question
Biology, 07.12.2020 03:30
question
English, 07.12.2020 03:30
question
Mathematics, 07.12.2020 03:30
Questions on the website: 13722360