class ArrayStringStack { String stack[]; int top; public arrayStringStack(int size) { ...

60.1K

Verified Solution

Question

Programming

class ArrayStringStack{ String stack[]; int top; public arrayStringStack(int size) {  stack = new String[size];  top = -1; } //Assume that your answers to 3.1-3.3 will be inserted here, ex: // full() would be here //empty() would be here... //push()  //pop()  //displayStack() }

1. Write two boolean methods, full( ) and empty( ).

2. Write two methods, push( ) and pop( ). Note: parameters maybe expected for push and/or pop.

3. Write the method displayStack( ) that prints the stack like astack, from top to bottom.

In java

Answer & Explanation Solved by verified expert
4.5 Ratings (791 Votes)
public class ArrayStringStack String stackint toppublic ArrayStringStackint sizestack new Stringsizetop 1 full would be hereboolean full check top is equal size1return topstacklength1emptyboolean empty check top is 1    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students