Answered step by step
Verified Expert Solution
Question
1 Approved Answer
#ifndef STACKPAC #define STACKPAC template class Stack { private: T Element[n]; int counter; public: void clearStack() { counter = 0; } bool emptyStack() { if
#ifndef STACKPAC
#define STACKPAC
template
class Stack
{
private: T Element[n];
int counter;
public:
void clearStack()
{
counter = 0;
}
bool emptyStack()
{
if (counter == 0) return true;
else return false;
}
bool fullStack()
{
if (counter == n) return true;
else return false;
}
void pushStack(T x)
{
Element[counter] = x;
counter++;
}
T popStack()
{
counter--;
return Element[counter];
}
};
#endif
Please complete the following program using C++. Please use beginner preprocessor directives and "STACKPACK.h library (dont use stdlib.h or bits/stdc++.h). Thank you! Write a program to read an integer number in n and a base (2,8,16 ) in newBase. Convert n from base 10 to newBase. Must use the "STACKPAC.h library. Sample run Enter a number at base 10: 35 Enter a new base (2,8,16): 2 35 base 10 is 100011 base 2 CONTINUE(y)? y Enter a number at base 10: 355 Enter a new base (2,8,16): 8 355 base 10 is 453 base 8 CONTINUE[y)? y Enter a number at base 10: 442 Enter a new base (2,8,16): 16 442 base 10 is 1BA base16 CONTINUE(Y)?nStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started