Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider the following coding that is developed to implement the Stack class of integers. class stack { int stck [ ] ; int tos; /

Consider the following coding that is developed to implement the Stack class of integers.
class stack {
int stck [];
int tos;
// Initialize top-of-stack
Stack(int arr[]){
stck=arr;
tos =-1
}
// Push an item onto the stack
void push(int item){
if (tos==9)
System.out.println("Stack is ful1.");
else
stck [++tos]= item;
}
// Pop an item from the stack
int pop(){
if (tos 0){
System.out.println("Stack underflow.");
return 0 ;
e1se
}
return stck[tos--];
}
}
We are now interested to make an interface StackInterface that has functionally to push and
pop with a generic datatype T. Modify the class Stack that will implement StackInterface.
Also, in the driver class make stacks of integer, double and push and pop 3 items of each category
in the stacks.
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Visual Basic 6 Databases

Authors: Charles Williams

1st Edition

1861002025, 978-1861002020

More Books

Students also viewed these Databases questions