Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Create a class called GenericStack that uses a linked list to implement a stack, which is a collection that lets you access entries on a first-in, last-out basis. Then you'll create another class that uses the GenericStack class.

The GenericStack class should implement these methods.

Push(element): Adds an element to the top of the stack.
Pop(): Returns and removes the element at the top of the stack
Peek():Returns but does not remove the element at the top of the stack.
Size(): Returns the number of entries in the stack.

A. Create a GenericStack class

i. Create a new class named GenericStack that specifies a type variable that provides for generics.

ii. Declare a linked list that will hold the elements in the stack. Then, use the linked list to implement the methods listed above.

B.. Create a class that uses GenericStack class

i. Open the GenericStackApp class. Then declare a generic stack at the beginning of the main method that will store-String objects.

ii. Add code to the main method that uses the push method to add at least 3 items to the stack. After each item is added, display its value at the console. Then use the size method to return the number of items in the stack and display that value

iii. Use the peek method to return the first item and display that item and use the size method to return the number of items again and display that value

iv.Use the pop method to return each item, displaying it as its returned and display the number of items one more time.

v. Output will be as follows:

Push: Apples
Push: Oranges
Push: Bananas

The stack contains 3 items

Peek: Bananas

The stack contains 3 items

Pop: Bananas
Pop: Oranges
Pop: Apples

The stack contains 0 items.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M92020756
  • Price:- $40

Priced at Now at $40, Verified Solution

Have any Question?


Related Questions in Computer Engineering

Garber and skinner suggest that the large per capital

Garber and Skinner suggest that the large per capital health spending in the US (and relatively low returns to health) are due to productive and allocative inefficiencies. Which inefficiency (if either) do you think char ...

An inhaled anesthetic of formula c2hbrclf3 is unusual in

An inhaled anesthetic of formula C2HBrClF3 is unusual in that it contains three different halogen atoms but no oxygen. What is its pressure in atmospheres at 27°C if its density is 0.187 g/L at that temperature?

What are some of the skill sets required for the various

What are some of the skill sets required for the various aspects of cloud administration. Are there any certifications related to cloud computing? Is there value in obtaining one of these certifications?

Aaninformationretrievalsystemhasacertainpairofaverageprecisi

(a) An information retrieval system has a certain pair of average precision and recall values when the system returns 10 documents in response queries. Would the precision and recall rate remain unchanged if the system w ...

Quesiton for completion of the program use arrays and

Quesiton: For completion of the program, use arrays and files. Instead of prompting the user for the prices of the book, update the website program to reflect the following changes: • Read the prices into an array from a ...

How can word processing software give a person the ability

How can Word Processing software give a person the ability to better position themself or a business, in today's society? Why?

A study was conducted of pleas made by 1032 criminals among

A study was conducted of pleas made by 1,032 criminals. Among those criminals, 954 pled guilty, and 394 of them were sentenced to prison. Among the 78 of the other criminals, who pled not quilty, 58 were sentenced to pri ...

Why is it important to back up the dhcp database and

Why is it important to back up the DHCP database and Identify key files that make up the DHCP database?

Please discuss the design principles that guide the authors

Please discuss the design principles that guide the authors of instruction sets in making the right balance. Provide examples of application of each of the three design principles while designing instruction sets.

What are the differences between four types of economics

What are the differences between four types of economics evaluations and their differences with other two (budget impact analysis (BIA) and cost of illness (COI) studies)?

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As