Write an independent method public long removesecond

Assignment Help JAVA Programming
Reference no: EM131602725

Stacks and Queues

(independent simply means that the method works right no matter what class it is in).

Exercise 1
Write an independent method public long removeSecond (StackX stack): It removes and returns the element just below the top element if the stack has at least two elements, otherwise it simply returns null without modifying the stack.


Exercise 3 (harder)
Write an independent method
public static void removeDownTo (StackX stack, long ob): It pops all values off the stack down to but not including the first element it sees that is equal to the second parameter. If none are equal, leave the stack empty.

Exercise 4 (harder)
Write an independent method public static Object removeSecond (Queue queue): It removes and returns the element just behind the front element. Precondition: The queue has at least two elements. Hint: Create a new object totally different from any that could possibly be on the queue.


Exercise 5*
Write an independent method
public static void transfer (StackX one, StackX two): It transfers all elements in the first parameter onto the top of the second parameter, keeping the same order. So what was initially on top of one ends up on top of two . Hint: Use a third stack temporarily.

Exercise 6*
Write an independent method public static void reverse (Queue queue): It reverses the order of the elements on the queue.

Exercise 7**
Write an independent method
public static void removeBelow (Queue queue, long ob): It removes all values from the queue that come after the first element it sees that is equal to the second parameter. If none are equal, leave the queue as it was originally.

Exercise 8**
Write an independent method named
interchange(StackX one, StackX two): You have two StackX parameters. All the items on each stack are to end up on the other stack in the same order, so that each stack has the items that the other stack had at the beginning. Use only one additional temporary stack.


Exercise 10 (harder)
Add a method public boolean equals (long ob)to the StackX class: The executor tells whether ob is an StackX whose elements are equal to its own in the same order.

Exercise 11*
Add a method public int search (long ob)to the StackX class: The executor tells how many elements would have to be popped to have ob removed from the stack; it returns -1 if ob is not in the stack.


Exercise 14.14
Add a method public String toString() to the Queue class: The executor returns the concatenation of the string representation of all elements currently in the queue with a tab character before each element, in order from front to rear. This is very useful for debugging purposes.

Exercise 14.15 (harder)
Write a method public void removeAfter (long ob)
that could be added to Queue: The executor removes all values from the queue that come after the element closest to the rear that is equal to the parameter. If none are equal, leave the queue as it was originally. Handle ob == null correctly.

Exercise 14.16*
Add a method public boolean equals (long ob) to the Queue class: The executor tells whether ob is an Queue with whose elements are equal to its own in the same order. Do not throw any Exceptions.

Exercise 14.17*
Add a method public void clear() to the Queue class: The executor deletes all the elements it contains, thereby becoming empty.

Attachment:- Program.rar

Reference no: EM131602725

Questions Cloud

Explain two depictions of women : Compare and contrast these two (2) depictions of women, and comment on any general tendencies that you detect among artists of that era in this respect.
Correlation between unemployment and inflation : 1. What is the correlation between unemployment and inflation? 2. In your opinion, do you believe that this correlation is true of the current economy?
Active monetary and fiscal policy : Select two subjects from the following list of topics and write a 1,050-word analysis:
Determine points at which tangent line touches each circle : Sketch the circles y2 + x2 = 1 and y2 + (x - 3)2 = 4. There is a line with positive slope that is tangent to both circles.
Write an independent method public long removesecond : Write an independent method public long removeSecond (StackX stack): It removes and returns the element just - Write an independent method
Economics in the non-us based model : Identify and analyze how politics has influenced health care economics in the non-U.S. based model you chose.
Define technology and media connect people to the community : How does technology and media connect people to the community. What are the effects of these connections on human well-being
Define the terms science and pseudoscience : Define the terms 'science' and 'pseudoscience'. Thoroughly explain the difference between them and provide your references.
Discuss motivate an individual in a particular situation : Discuss how you would use principles from the chapter to motivate an individual in a particular situation

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd