Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The store manager decided to giveaway Giants and Jets t-shirts to their customers since they were shutting down the business. People supporting their team

image text in transcribed

The store manager decided to giveaway "Giants" and "Jets" t-shirts to their customers since they were shutting down the business. People supporting their team had to carry a sign that says whether they are "Giants" fan of "Jets". Store manager has no other employee to help him out and had all the t-shirts piled up in one single pile. So he came up with his own rule. The rule is simple: If customer in a queue is carrying sign that says "Giant" AND t-shirt on the pile is "Giants" t-shirt (or if customer in a queue is carrying sign that says "Jets" AND t-shirt on the pile is "Jets" t-shirt) then customer takes the t-shirt and leave the queue otherwise customer joins back queue at the end of the line. This continues until none of the queue customer want to take the top t-shirt or there are no more t-shirts left. You need to design you program to find out how many customer will end up getting no t-shirts. Example Input and output: Input(two arrays of String): Output(integer) :0 compare new state compare new state compare new state compare new state compare new state Step by step process for sample input/output: Operation t-shirt Customer (front,.....,end) J, G, J, G J, G, J, G J, G, J, G G, J, G G, J, G G, J, G G, J, G J, G J, G J, G } compare new state G compare G new state empty J, G customers [G,G,J,J] Queue Lab (front,.....,end) G, J, J, G J, J, G, G J, J, G, G J, G, G J, G, G G, G, J G, G, J G, J G, J J, G J, G G G empty t-shirts [J,G,J,G] Explanation J!= G send customer back to queue J == J customer take the t-shirt and leaves queue G != J send customer back to queue G == G customer take the t-shirt and leaves queue J!= G send customer back to queue J == J customer take the t-shirt and leaves queue G == G customer take the t-shirt and leaves queue MyQueue.java import java.util.LinkedList; import java.util.Queue; public class MyQueue{ public int count CustomerWithoutTshirt(String[] customer, String[] tshirt) { Queue q = new LinkedList (); // write your logic here Put all your work in ONE Zip file and submit it in Canvas. Zip filename should be in format of FirstLast_Lab5.zip (ex. John Doe_Lab5.zip) Zip file should contain 4 files only: (1) MyQueue.java (2) Demo.java (3) Output.docx (screenshot of input and output) (4) Pseudo-code.docx (provide pseudo-code)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Management Accounting Information for Decision-Making and Strategy Execution

Authors: Anthony A. Atkinson, Robert S. Kaplan, Ella Mae Matsumura, S. Mark Young

6th Edition

137024975, 978-0137024971

More Books

Students also viewed these Programming questions