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 20:30
Column a of irma’s spreadsheet contains titles for each row, but her document is too big and will be printed three pages across. she wants to be sure that every page will be understood. what can irma do to with this problem?
Answers: 3
question
Computers and Technology, 25.06.2019 17:00
Match each word to its correct meaning. 1. quick launch an area that displays icons representing open applications 2. shortcut an icon used to represent an application, a file, or a folder 3. start menu an area on the taskbar where icons representing programs that are always running are displayed 4. system tray a list of programs that can be opened by clicking on their names or icons 5. taskbar an area on the taskbar from which frequently used programs can be opened pls. will get brainlist
Answers: 1
question
Computers and Technology, 25.06.2019 22:00
Which of the following describes the operating system? a. it commands and controls all of the hardware and other software applications b. it contains the circuitry that processes the information coming into the computer c. it is one of the physical components of the computer d. it can be divided into two categories: input and output
Answers: 1
question
Computers and Technology, 26.06.2019 02:00
To activate the laser pointer, what would you press and/or click? a. ctrl + left mouse button b. ctrl + p c. esc key d. n key
Answers: 2
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, 29.07.2019 17:30
question
Mathematics, 29.07.2019 17:30
Questions on the website: 13722361