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

  Define two different physical representations for strings

Define an ADT for character strings. Your ADT should consist of typical functions that can be performed on strings, with each function defined in terms of its input and output. Then define two different physical representations for strings.

  Describe the applications functionality

Create an application for Koch's Cottages, a weekend getaway resort that rents cottages and boats to use on the local lake - Add labels as suitable to describe the application's functionality. Save the file as JCottageFrame.java.

  Design and implement a small and simple email server using

design and implement a small and simple email server using the concept of web based information system wbis. your

  Prepare an address book to save the complete information

Prepare an address book to save the complete information of the person - Define the class Address that can store a street address, city, state, and zip code. Use the appropriate methods to print and store the address.

  Part-11 suppose we have a rectangle class that includes

part-11. suppose we have a rectangle class that includes length and width attributes of type int both set by the

  Organization structure change over time

How and why did the organization structure change over time, and in what ways were some of these changes responsible for some of their recent problems?

  Tasks for an array of integers

Write array methods that carry out the subsequent tasks for an array of integers by completing the ArrayMethods class below. Test each method.

  Bull write a blog article for a coding and technical

bull write a blog article for a coding and technical community blog.bull the length of the article is to be between 500

  Write down several reasons why exception-handling

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

  Wa program that takes 10 values represent

Using a loop, write a program that takes 10 values represent in exam grades (between 0 and 100) from the keyboard and outputs the minimum value, maximum value, and average value of all the values entered.

  Generate and manipulate music and images

Arrays are a fundamental and versatile tool for representing data of all shapes and sizes In this assignment, you'll see how arrays can be applied to generate and manipulate music and images.

  Redesign the grading program as an object-oriented design

Redesign the grading program as an object-oriented design. We will start with a simple Student class. The student will have a name, an id (as a String) and a set of grades (as doubles).

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