Demonstrate all of the methods of your stack.

Assignment Help JAVA Programming
Reference no: EM13718647

Write a program that uses a stack to reverse its inputs. Your stack must be generic and you must demonstrate that it accepts both String and Integer types. Your stack must implement the following methods:

  • push,
  • pop,
  • isEmpty (returns true if the stack is empty and false otherwise), and
  • size (returns an integer value for the number of items in the stack).

You may use either an ArrayList or a LinkedList to implement your stack. Also, your pop method must throw an IndexOutOfBoundsException if the user attempts to "pop" something off an empty stack. Name your stack class "Stack" and put it in a file named Stack.java.
Create a StackTest.java file to demonstrate all of the methods of your stack. Instantiate two stacks; one for String and one for Integer. Push words/integers onto your stack. After you have pushed a series of words/integers on your stack use a while loop to pop and print each item. If your stack is working properly your inputs should print in reverse order. Be sure that you calls to pop are in a try statement and will catch the IndexOutOfBoundsException, if thrown.
Note: Java has a Stack class, but you may not use it. You must create your own Stack class and your class must have the following operations (all of which must be demonstrated): push, pop, isEmpty, and size.

 

Reference no: EM13718647

Questions Cloud

What is the uncertainty in the concentration of the unknown : Amount of cadmium in a sample is determined by AAS. The standard solutions produce a straight calibration curve with a slope of .1024 + .0082 abs units/ppm. And a y intercepts of .0105 + .0076 abs units. What is the uncertainty in the concentratio..
Calculate the chromatographic resolution for compounds : Compound Y has a reflection time of tR = 12.07 min with N =16,250 theoretical plates. Calculate the chromatographic resolution for these two compounds.
What was the inflation rate the past years : Look at the economy's economic growth rate and see if it grew substantially after a time period. Why? For example when Japan (after the Tokugawa period) opened up their economy for more trade their economy grew substantially.
Determine the mass of ga in the sample : 50 ml if .15M NaNO was added to a sample containing gallium. Nitrate oxidized Ga(s) to Ga(aq). The resulting nitrous acid was titrated to the equivalence point with 27.82 mL of .1M NaOH. Determine the mass of Ga(s) in the sample
Demonstrate all of the methods of your stack. : Create a StackTest.java file to demonstrate all of the methods of your stack. Instantiate two stacks; one for String and one for Integer. Push words/integers onto your stack. After you have pushed a series of words/integers on your stack use..
Explain which pair should have the higher melting point : Which member of each pair should have the higher melting point? Use intermolecular forces to explain why.a. CO2 or CCl4
Carbon dioxide dissolves in water and water evaporates : Carbon dioxide dissolves in water and water evaporates into the atmosphere during the experiment. How do these two factors affect the results of your analysis in this experiment? Where an experiment of an Alka Seltzer tablet is put in a mixture of..
Explain the mechanism for the reaction of trans-2-hexene : Does the epoxidation of trans-2-hexene produce a single enantiomer, meso compound, or racemic mixture? Explain your reasoning and show the mechanism for the reaction of trans-2-hexene with MCBPA.
Find the number density of oxygen molecules in the gas : The density of oxygen gas (O2, M= 32.00 g/mol) in a new oxygen gas cylinder, measured at T= 20 degrees Celsius, is 0.1632 g/ml. Find the following-

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