Question: Write a Java program that uses recursion throughout to do the following in sequence : creates a queue of strings enter a set number of

Write a Java program that uses recursion throughout to do the following in sequence:

  • creates a queue of strings
    • enter a set number of strings at the keyboard or
    • get the strings from an input file
  • displays the original contents of the queue
  • reverses the contents of the queue
  • displays the contents of the queue in reverse

Here's a program run of a program where recursion was used to do each of the above tasks:

Create a queue:

How many names?

6 Enter a name

Joe

Enter a name

Jess Enter a name

Jim Enter a name

Jill Enter a name

Jane Enter a name

Jerry

Original contents of the queue:

Joe Jess Jim Jill Jane Jerry

Contents of the queue in reverse:

Jerry Jane Jill Jim Jess Joe

Create a queue:

How many names?

10

Enter a name

Jane

Enter a name

Jack

Enter a name

Jill

Enter a name

Joseph

Enter a name

Janna

Enter a name

John Enter a name

Jenny

Enter a name

Jacob Enter a name

Jennifer

Enter a name

Jonathan

Original contents of the queue:

Jane Jack Jill Joseph Janna John Jenny Jacob Jennifer Jonathan =====================================================================

Contents of the queue in reverse: Jonathan Jennifer Jacob Jenny John Janna Joseph Jill Jack Jane

=======================

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!