Question: USE C + + : USE STACK AND QUEUE Introduction In this assignment, you will work with a queue and stack to learn more about
USE C: USE STACK AND QUEUE
Introduction
In this assignment, you will work with a queue and stack to learn more about its use and
functionality. There is a new game in the casino, and you are supposed to figure out who is
losing the game. Every participant will ask for a number of red and black cards the numbers
should add up to Then the dealer will stack some random black and red cards on top of
each other. Participants form a queue and the dealer will deal them the stack of cards until
they reach the number of cards that they asked in the beginning. if the element of the top of
the stack changes, the participant will go to the end of the queue. After the stack ends,
anyone who hasn't received the cards that they called for is a loser.
Input files
The input file will contain a list of credentials ranging from to
Each credential represents a participant and needs to be added to a queue.
Each credential will have three attributes: Name, the number of Black cards they
asked for, and the number of Red cards. Note: Name will always contain alphabet
characters azAZ no spaces or special characters included. The numbers will be in
the form of a doubledigit number, the tens is the number of blacks and the ones is the
number of Reds. The formatting of each credential is as follows:
Name, xy
Note that xy is always equal to x is the number of black cards and y is the number of
red cards
You can safely consider that all the inputs are in the correct format but it can be empty. In
this case output: No Game!".
While reading the input, In and r should be removed before processing the string.
Command files
Each line will have a number of cards and a letter indicating the color of the cards.
For instance, the following is a valid command file:
Bbottom of the stack
R
R
B
Rtop of the stack
This file can empty
You will have to store the data in a stack
While reading the command,
and r should be removed before processing the string.
Output files
The output file should display the name of the losers in the order that they are in the queue.
If there was no participant empty input return No Game!"
If there is no loser, return No Loser!"
Each name will be on its own line.
The Operations
The dealer will give the person in the front of the queue the cards on
the top of the stack.
If no one needs the cards that are at the top of the stack, those cards are burned
and the program starts using the next element of the stack. No one means you have to
go over the queue once and make sure that everyone's that color is Make sure that
the queue order does not change in this step.
A participant will move to the end of the queue if the stack's element
changes. Like from the R cards are already given and you will move to
the next element which is B
A participant will move to the end of the queue if they get all the cards
of one color that they asked for.
A participant is a winner if they get all the cards that they asked for
from both colors.
People who remain in the queue after the stack of cards ends are the losers.
EXAMPLE OF INPUT FILE CONTENTS:
Tony,
Sofia,
Sara,
Maria,
EXAMPLE OF COMMAND FILE:
R
R
B
R
B
B
EXPECTED TO BE IN OUTPUT FILE:
Maria
Sara
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
