Question: Use the implemented stack on the Lab manual ( using array ) to write a complete C + + program that contain the following: A

Use the implemented stack on the Lab manual (using array) to write a complete
C++ program that contain the following:
A function to fill up stack with randomly characters (from a-z and A-Z only)4pts
A function to split this stack into two separated stacks; the first stack must only
contain the upper-case characters and the second stack must only contain the
lower-case characters. 4pts
main function to test the previous two functions and display the content of the
three stacks. 2pt
Sample output:
Input stack : a , A , u , P , j , e , N , I , N
First stack : A , P , N , I , N
Second stack: a , u , e
Notes:
Dont use #include or any other external libraries to solve the question (
you can only use #include using name space std or
#include )
The output must be exactly as mentioned.
mplemented stack on the Lab manual (using array) :
template
class Stack { int topindex;
T entry[MAX]; // Maximum size of Stack
public:
Stack(){ topindex =0; }
bool Push(T x)
{
if (topindex >= MAX)
return false;
entry[topindex++]= x;
return true;
}
bool Pop()
{
if (topindex =0)
return 0;
topindex--;
return 1;
}
bool Top(T &x)
{
if (topindex =0)
return 0;
x = entry[topindex-1];
return 1;
}
bool Empty()
{
return (topindex ==0);
}
};
template
void print(Stack s)
{T item;
while (!s.Empty())
{
s.Top(item);
cout
void fill(Stack &s, int n)
{
for (int i=1;i=n;i++)
s.Push(rand()%100);
}
Use the implemented stack on the Lab manual (

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!