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

  Java program asks the user to input the number of gallons

Write a java program asks the user to input the number of gallons of gas in the tank and the price of gas per gallon

  Simulate some people catching fish in a lake in java program

In this project, you will simulate some people catching fish in a lake. The purpose of the assignment is to get used to using Arrays as well as getting more experience in having objects interact together.

  Write down several reasons why exception-handling

question 1 give several reasons why exception-handling techniques should not be used for conventional program

  Define a method for linkedbag

Add a constructor to the class LinkedBag that creates a bag from a given array of entries - define a method for LinkedBag that removes a random entry from the bag.

  Alter the prototype form page by javascript function

Alter the prototype form page so that when JavaScript function has verified that all the required fields have been filled, cookie is added to user's computer.

  Create a dice game that uses a six-sided die

Create a dice game that uses a six-sided die - Using switch statements print the face of the die based on the value obtained.

  Write class encapsulating the concept of weather forecast

Write a class encapsulating the concept of the weather forecast, assuming that it has the given attributes: the temperature and the sky conditions, which could be sunny, snowy, cloudy, or rainy.

  This is a simulation of rolling dice actual results

this is a simulation of rolling dice. actual results approach theory only when the sample size is large. so we will

  Design and implement a sorting algorithm

Your task is to design and implement a sorting algorithm and running time grows as a linear function of the array

  Write a graphical user interface class

Write a graphical user interface class called SentenceCounterGUI. It should be able to manipulate the sentence of words and have the behaviour label.

  Explain the legal doctrine benefits balancing

Explain the legal doctrine "Benefits Balancing" as it pertains to applying the reasonable standard of care doctrine in the medical fields. Does a defense that the majority of physicians normally do not give a particular diagnostic test in the normal ..

  Javascript validation - cgi program

CGI mailer script form-mail.pl to your server's cgi-bin directory, and change the permissions on the script to make it executable - BMIS 310

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