555309 Stacks and Queues

Em Andamento Postado Mar 6, 2012 Pago na entrega
Em Andamento Pago na entrega

The unfortunate effects of the University-wide budget cuts are seemingly limitless, with practically every department hurting in some way. Due to lack of funding, the online class registration portal is no longer available; we've turned back the clock about twenty years! In order to register for classes, you must be physically present at the Registrar's Office in Millican Hall. (If it makes you feel any better, all UCF students are in the same boat!) Upon arriving to the Registrar's office (which runs from 12:00 PM to 5:00 PM, 7 days a week), you notice a massive line of students thinking the same thing as you, “You have GOT to be kidding me!” Sorry buddy: welcome to the current economy! So, with really no choice left, you must get into this crazy line in order to register. Fortunately the process is streamlined and relatively straightforward, although possibly WAAAY time consuming!

As you get closer to the front of this seemingly endless line, you notice that you won't actually register via another human. Rather, once a student reaches the front of the line, they briefly interact with a Laptop Dispensing Minion (LDM), who issues them a laptop (from a stack of laptops) that gives them access to the registration portal via UCF's internal intranet. You're thinking: “Budget cuts forced the online registration portal to be shut down; yet, UCF can somehow afford all these laptops to register with!” You are set at ease, however, upon grabbing yours. Reminding you of the Star Wars intro, “A long time ago in a galaxy far, far away...”, these massive bricks, err, um laptops, are most likely from the '90s, sporting some ancient version of Microsoft Windows along with a barely working internet browser. Amazingly, however, they do they work, albeit very slowly. To add insult to injury, however, there are only five laptops! So not only must students wait in this excessively long laptop line, but even once at the front, they may have to wait for one of these rockstar laptops to become available.

Once a student is issued a laptop, they will then spend exactly five minutes registering for classes. For the purposes of this simulation, once the five minutes are up, we will assume that they student has finished their registration. The student must then get into a separate laptop return line, which is, thankfully, a lot quicker than the laptop waiting line (cuz there are only five laptops). Once students are at the front of the return line, they briefly interact with a Laptop Returning Minion (LRM), who confirms the registration is correct, prints out a confirmation page for the student, and places (pushes) the laptop back on the stack of laptops. All registrations are saved in an alphabetical linked-list for the purpose of printing the UCF Daily Registration Report. As in real life, some students will make mistakes with their registration (the input file will detail which students will make mistakes and which ones will not). Upon reaching the front of the laptop return line and interacting with the LRM, and if this student made mistakes, the LRM will inform the student that there are mistakes with the registration. This student will then spend another five minutes correcting the mistakes, and they will then re-enter the laptop return line. It is guaranteed that the five-minute redo will fix the mistakes.

Your Assignment is to write a simulation that models the aforementioned Registration over n number of days, where the simulation runs over each minute of every day, from 12 PM to 5 PM.

Odd Jobs

ID do Projeto: #2301261

Sobre o projeto

Projeto remoto Ativo em Jul 11, 2012