1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
nata0808 [166]
3 years ago
15

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.
Computers and Technology
1 answer:
Nesterboy [21]3 years ago
4 0

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.

You might be interested in
Ryan needs to see the space available to insert content on a slide in his presentation. Which feature of presentation program sh
emmainna [20.7K]

He should use the Format feature.

4 0
4 years ago
Read 2 more answers
Which of the following form a set of angles of a triangle ?
Vsevolod [243]

Answer:

I think it is the first set

8 0
3 years ago
LIST THE SKILLSET NEEDED FOR BECOMING A PROGRAMMER.
wolverine [178]

Answer:

Proficiency with programming languages.  

Learning concepts and applying them to other problems.  

Mathematical skills.  

Problem-solving capability.  

Communication skills.

Writing skills.  

Inquisitiveness.  

Self-motivation.

7 0
3 years ago
Who was the first inventor of computer​
astraxan [27]

Answer:

Explanation:

English mathematician and inventor Charles Babbage is credited with having conceived the first automatic digital computer. During the mid-1830s Babbage developed plans for the Analytical Engine.

3 0
3 years ago
Read 2 more answers
Help please and thank you :)
Fynjy0 [20]
Answer:First one net is the answer ........
5 0
3 years ago
Other questions:
  • Create a Java program with threads that looks through a vary large array (100,000,000 elements) to find the smallest number in t
    10·1 answer
  • Trading your bicycle for a snowboard exemplifies ?
    15·1 answer
  • How do Filament 3D printers build a model?
    8·1 answer
  • The Spanning Tree Protocol operates at the Network layer of the OSI model.
    13·1 answer
  • Gaming applications allow users to play solo games as well as play with friends and/or other players
    11·1 answer
  • Describing the One-to-Many Relationship
    13·2 answers
  • Which of the following situations is least likely fair use
    6·2 answers
  • How do I get the pictures from my old Samsung phone to put on my iPhone? The Samsung is turned off. Is there a way to transfer i
    8·1 answer
  • Which transform function would you use to operate the filename values into two separate columns, one for the filename and the ot
    15·1 answer
  • you're building a new network for a small financial services startup company. security is paramount, so each organization within
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!