Reference no: EM131266003
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.
How to calculate charges if user returns the book late
: How to calculate charges if user returns the book late? How to determine the book condition/depreciation? Provision of scanning the barcode instead of entering the data manually.
|
Movement along the same demand curve for product
: What happens to the demand curve and the supply curve when any of these determinants change? What would cause a change in demand versus a movement along the same demand curve for this product?
|
Uses weighted average with a periodic inventory system
: During 2012, a company sells 300 units of inventory for $85 each. the company has the following inventory purchase transactions for 2012: DATE TRANSACTION NUMBER OF UNITS UNIT COST TOTAL COST jan. calculate ending inventory and cost of goods sold for..
|
Balance sheet for its investment in burke corporation
: Gilman Company purchased 100,000 of the 250,000 shares of common stock of Burke Corporation on January 1, 2009, at $40 per share as a long-term investment. The records of Burke Corporation showed the following on December 31, 2009: balance sheet for..
|
Declare linked list that will hold the elements in the stack
: Create a new class named GenericStack that specifies a type variable that provides for generics. Declare a linked list that will hold the elements in the stack. Then, use the linked list to implement the methods listed above.
|
Discuss four components of corporate social responsibility
: Discuss the four components of corporate social responsibility (CSR) and how they relate to a charitable campaign such as (Product) RED.
|
Decrease short-term interest rates
: Suppose that the Federal Reserve is concerned about deflation in the future, so they decrease short-term interest rates. How will this affect long-term rates and the yield curve?
|
Appraisal value of this acquired land
: On May 26, 2012, the Georgia Corp. acquired a piece of land by issuing 60,000 shares of its $9 par value common stock. The list price of the land was $625,000 and on May 26, 2012, Georgia's common stock was actively trading in the marketplace at $10 ..
|
Describe the effects of paralysis on the skeleton
: 1. Following a severe spinal cord injury in the lumbar region, the voluntary muscles of the legs and hips will be paralyzed. Describe the effects of paralysis on theskeleton.
|