Question: Given the program: importjava.util.Stack; public class SweetCandy { public static void main(String [ ] args) { Stack container = new Stack( ); container.push (new Candy(Purple));

Given the program:

importjava.util.Stack;

public class SweetCandy

{

public static void main(String [ ] args)

{

Stack container = new Stack( );

container.push (new Candy("Purple"));

container.push (new Candy("Green"));

container.push (new Candy("Yellow"));

container.push (new Candy("Purple"));

container.push (new Candy("Blue"));


 write your code here to remove all the candies from the container, "eat" the purple ones, and return all the other candies to the container in the original order. Print out the candies left in the container. BOX IN THE OUTPUT OF THE PROGRAM*/

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

import javautilStack public class SweetCandy public static void mainString args Stack Candy containe... View full answer

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!