Hi please help tq so much . #ifndef STACK_H #define STACK_H const int MaxSize = 10; template class Stack { public : Stack(); ~Stack(); void Push(MyData); void Pop(); MyData TopStack(); bool...


Hi please help tq so much .


#ifndef STACK_H


#define STACK_H


const int MaxSize = 10;


template


class Stack


{


public :


Stack(); ~Stack(); void Push(MyData); void Pop(); MyData TopStack(); bool Underflow(); bool Overflow(); private : int Top; MyData MyArray[MaxSize]; }; #endif template Stack::Stack() {Top = -1;} template Stack::~Stack() {} template void Stack::Push(MyData item) { Top++; MyArray[Top]=item; } template void Stack::Pop() { Top--; } template MyData Stack::TopStack() { return MyArray[Top]; } template bool Stack::Underflow() { return (Top == -1); } template bool Stack::Overflow() { return (Top == MaxSize-1); }





INSTRUCTIONS:


i) By displaying the value in horizontal, what is theoutput of the program? Write your answer in the text box below.

ii)UPLOADyour answerStackMain.cpp into the box below.

FILE: Stack.h<br>Given the Stack.h above and the following data is to be entered by a user:<br>{ 83, 84, 65, 82, 71, 78, 79, 67 }<br>Write a main program that uses Stack.h library to perform the following pseudo-code:<br>1. create stack S1 and stack S2 as character<br>2. start loop 8 times<br>3.<br>accept data from user<br>4.<br>if the data entered is odd number<br>5.<br>push into S1<br>6.<br>else if the data entered is even number<br>7.<br>push into S2<br>8. end loop<br>9. display top S1<br>10. роp S1<br>11. start loop S2 is not empty<br>12.<br>display top S1<br>13.<br>pop S1<br>14.<br>display top S2<br>15.<br>pop S2<br>16. end loop<br>17. display top S1<br>18. роp S1<br>INSTRUCTIONS:<br>i) By displaying the value in horizontal, what is the output of the program? Write your answer in the text box<br>below.<br>ii) UPLOAD your answer StackMain.cpp into the box below.<br>

Extracted text: FILE: Stack.h Given the Stack.h above and the following data is to be entered by a user: { 83, 84, 65, 82, 71, 78, 79, 67 } Write a main program that uses Stack.h library to perform the following pseudo-code: 1. create stack S1 and stack S2 as character 2. start loop 8 times 3. accept data from user 4. if the data entered is odd number 5. push into S1 6. else if the data entered is even number 7. push into S2 8. end loop 9. display top S1 10. роp S1 11. start loop S2 is not empty 12. display top S1 13. pop S1 14. display top S2 15. pop S2 16. end loop 17. display top S1 18. роp S1 INSTRUCTIONS: i) By displaying the value in horizontal, what is the output of the program? Write your answer in the text box below. ii) UPLOAD your answer StackMain.cpp into the box below.
#ifndef STACK_H<br>#define STACK_H<br>const int MaxSize = 10;<br>template<class MyData><br>class Stack<br>{<br>public :<br>Stack ();<br>-Stack();<br>void Push(MyData);<br>void Pop();<br>MyData TopStack();<br>bool Underflow();<br>bool Overflow();<br>private :<br>int Top;<br>MyData MyArray[MaxSize];<br>};<br>#endif<br>template<class MyData><br>Stack<MyData>: :Stack()<br>{Top = -1;}<br>%3D<br>template<class MyData><br>Stack<MyData>::-Stack()<br>{}<br>template<class MyData><br>void Stack<MyData>::Push(MyData item)<br>{<br>Тop++;<br>MyArray[Top]=item;<br>}<br>template<class MyData><br>void Stack<MyData>::Pop()<br>{ Top--; }<br>template<class MyData><br>MyData Stack<MyData>::TopStack()<br>{ return MyArray[Top]; }<br>template<class MyData><br>bool Stack<MyData>::Underflow()<br>{ return (Top == -1); }<br>template<class MyData><br>bool Stack<MyData>::0verflow ()<br>{ return (Top<br>MaxSize-1); }<br>==<br>

Extracted text: #ifndef STACK_H #define STACK_H const int MaxSize = 10; template class Stack { public : Stack (); -Stack(); void Push(MyData); void Pop(); MyData TopStack(); bool Underflow(); bool Overflow(); private : int Top; MyData MyArray[MaxSize]; }; #endif template Stack: :Stack() {Top = -1;} %3D template Stack::-Stack() {} template void Stack::Push(MyData item) { Тop++; MyArray[Top]=item; } template void Stack::Pop() { Top--; } template MyData Stack::TopStack() { return MyArray[Top]; } template bool Stack::Underflow() { return (Top == -1); } template bool Stack::0verflow () { return (Top MaxSize-1); } ==
Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here