Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

using c++ In a container of candies there are 3 colors randomly placed: red, yel

ID: 3650655 • Letter: U

Question

using c++
In a container of candies there are 3 colors randomly placed: red, yellow and blue. Assume that the container holds a maximum of 12 candies. Use a stack program to simulate randomly placing some (between 5 and 12 candies) initially into the container (stack).
Now once that is done have the "user" choose a color and using ONLY stack functions remove all candies of that color. All candies in the container (stack) that are NOT of that color are returned to the candy in the same order they were in prior to the color removal. Actually loop the program twice to simulate "filling" and "removing" two sets of candies. Don't assume that there are necessarily all colors of candy all the time...so for example someone might want all red candies but there might not be any red candies at that time.
Fill the container (or partially fill) only ONCE for each run. Here is an example:

Suppose you place candies in this order: R R Y B R B Y B Y R B B
Then the stack would look like this:
R
R
Y
B
R
B
Y
B
Y
R
B
B (top of stack)
If you asked to remove all yellow the resulting stack would be:
R
R
B
R
B
B
R
B
B (top of stack)

Explanation / Answer

#include # include using namespace std; const maxstack = 21; class stack_type { public: void clear_stack(); bool empty_stack(); bool full_stack(); void push(int numb); void pop(int& numb); int stack[maxstack]; int top; }; int main() { stack_type s; int i,n; s.clear_stack(); cout