Answered step by step
Verified Expert Solution
Question
1 Approved Answer
can someone give a hint in the right direction, I am having trouble making the while loop Ken's office hours are getting really fuill, and
can someone give a hint in the right direction, I am having trouble making the while loop
Ken's office hours are getting really fuill, and a long line is forming outside his office each time. The students decide that they are too smart to simply line up, and decide on implementing a system. The system is a queue, meaning the first student in the line is the frist person Ken will see. However, to make the system better, the students decide on adding two rules: 1. When a student joins the back of the line, if they are younger than the person in front of them they can move up one spot 2. When a student joins the line and their grade in the class is lower than the person in front of them, they can also move up one spot. Input Format If a student is joining the line, the input format is the student's first name then a space then their age, then a space, then their grade. When Ken helps the next student in line, removing them from the queue, the input is next. When the input is done, the input is end. Constraints The student name is always less than 100 characters. The student age is always less than 250 years. The student grade is always in between 0 and 100 inclusive. Output Format The output will be the order of the students currently in line. If the queue is empty. Output the word empty. Sample input o Rob 33 98 Sarah 29 100 Dave 43 27 Kodi 25 92 Shane 3297 Jodie 2005 end Sample Output Dave 43 27 Kodi 25 92 Shane 32 97 Jodie 29 95 Rob 33 98 Explanation o Rob joins the line 1. Rob Sarah, being younger than Rab, maves up into first in line. 1. Sarah, 2. Rob When Dave joins the line, his grade is worse than the person in front of him, so Dave maves in front of Rab. 1. Sarah, 2. Dave, 2. Rob Kodi joins the line, but is younger & has a lower grade than Rob). 1. Sarah, 2. Dave, 2. kodi 4. Rob Ken calls next, meaning the front of the line is removed. 1. Dave, 2. kodi, 3. Rob 1. Dave, 2. kodi, 3. Shane, 4. Rob 1. Dave, 2. kodi, 3. Shane, 4. Jodie, 5. RobStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started