Question: Write a Java program that implements a queue and stack. The program will ask users to: Input a number as the size. Input positive and

Write a Java program that implements a queue and stack. The program will ask users to:

  1. Input a number as the size.
  2. Input positive and negative numbers.
  1. If the number is positive, it will push it in to the queue.
  2. If the number is negative it will push it in to the stack.

Then the program will display back the elements of the queue which is the positive numbers with their summation at the end. And it will display back the elements of the stack which is the negative numbers with their summation at the end of the program.

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!