Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

programming in C, the input of the program has to follow just like in the example Welcome to Fly CS! As employee #2 (the CEO

programming in C, the input of the program has to follow just like in the example

image text in transcribed

image text in transcribed

Welcome to Fly CS! As employee #2 (the CEO is #1), you are tasked with writing a program to model how the company is planning to service customers at check-in to see how well it performs. Fly CS is trying a new approach where passengers belong to 3 different groups: Rich, Middle, and Poor. Did I mention that "honesty is the best policy!" is the companies slogan? When customers arrive, they go into the appropriate line Agents that are ready to serve customers serve Rich customers first (if any are waiting), then Middle (if any are waiting) and then finally Poor (if any waiting) Agents themselves are coming and going as they start their shift, end their shift, and take breaks. When an agent goes on break or ends their shift, they ALWAYS finish with the customer they are helping first before doing leaving. Your job is to write a program to model this. Input to the program (via stdin) is the following format: Jim Middle Sue start Mary Rich 4 15 The first character indicates P for passenger or A for Agent. Next is the name of the Passenger/Agent. Note: Agent names are unique - so you can assume no duplicates. Next is the class of the passenger (Rich/Middle/Poor) or "star" if an agent. Next is the arrival time (or when the agent starts to work). Last is the duration of how long it will take to serve the customer. For an agent this is how long before the agent works before break. Each of these fields are separated by a tab character and the line ends with a newline character. There is no header. End of the file is denoted with EOF (end of file) character You can assume that the input is sorted based on arrival time In your program, each of the Agents will be a thread that you create when the agent begins and you terminate when the agent ends their shift (or goes on break). When an agent starts to service a customer they do not pre-empt serving them if someone else of higher status comes along. Once you start serving a passenger, then you serve until completion! Output of the program will be the following format: To indicate an agent starting (time name starts) 5 Sue starts To indicate an agent taking a passenger to serve (time agent serves passenger) 5 Sue serves Jim To indicate a passenger completed check-in (time name checked-in) 9 Jim checked-in To indicate an agent completed their shift (time name stops) 20 Sue stops For the sample input given above the output would be 5 Sue starts 5 Sue serves Jim 9 Jim checked-in 9 Sue serves Mary 12 Mary checked-in 20 Sue stops Hlint: Be careful to protect your shared data by using locks to control access! Welcome to Fly CS! As employee #2 (the CEO is #1), you are tasked with writing a program to model how the company is planning to service customers at check-in to see how well it performs. Fly CS is trying a new approach where passengers belong to 3 different groups: Rich, Middle, and Poor. Did I mention that "honesty is the best policy!" is the companies slogan? When customers arrive, they go into the appropriate line Agents that are ready to serve customers serve Rich customers first (if any are waiting), then Middle (if any are waiting) and then finally Poor (if any waiting) Agents themselves are coming and going as they start their shift, end their shift, and take breaks. When an agent goes on break or ends their shift, they ALWAYS finish with the customer they are helping first before doing leaving. Your job is to write a program to model this. Input to the program (via stdin) is the following format: Jim Middle Sue start Mary Rich 4 15 The first character indicates P for passenger or A for Agent. Next is the name of the Passenger/Agent. Note: Agent names are unique - so you can assume no duplicates. Next is the class of the passenger (Rich/Middle/Poor) or "star" if an agent. Next is the arrival time (or when the agent starts to work). Last is the duration of how long it will take to serve the customer. For an agent this is how long before the agent works before break. Each of these fields are separated by a tab character and the line ends with a newline character. There is no header. End of the file is denoted with EOF (end of file) character You can assume that the input is sorted based on arrival time In your program, each of the Agents will be a thread that you create when the agent begins and you terminate when the agent ends their shift (or goes on break). When an agent starts to service a customer they do not pre-empt serving them if someone else of higher status comes along. Once you start serving a passenger, then you serve until completion! Output of the program will be the following format: To indicate an agent starting (time name starts) 5 Sue starts To indicate an agent taking a passenger to serve (time agent serves passenger) 5 Sue serves Jim To indicate a passenger completed check-in (time name checked-in) 9 Jim checked-in To indicate an agent completed their shift (time name stops) 20 Sue stops For the sample input given above the output would be 5 Sue starts 5 Sue serves Jim 9 Jim checked-in 9 Sue serves Mary 12 Mary checked-in 20 Sue stops Hlint: Be careful to protect your shared data by using locks to control access

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

Learning MySQL Get A Handle On Your Data

Authors: Seyed M M Tahaghoghi

1st Edition

0596529465, 9780596529468

More Books

Students also viewed these Databases questions

Question

What resources does WWE have and how valuable are they?

Answered: 1 week ago

Question

LO2 Identify components of workflow analysis.

Answered: 1 week ago