← Back to STL Containers
Question 498
Printer Job Scheduler
Printer Job Scheduler
Build a classPrintQueuethat serves print jobs first-come, first-served, storing each job's name and page count in aqueue. Methods: -void submit(const string& name, int pages): adds a job to the back. -string processNext(): removes the front job and returnsPrinted NAME (P pages), e.g.Printed report (5 pages). With no jobs, returnsNo jobsand changes nothing. -int pendingPages() const: total pages still waiting (0 when empty). -int size() const: jobs still waiting. Test 1 submits report (5 pages) and photo (7 pages), then printspendingPages(),processNext(),pendingPages(),size(),processNext(),processNext(), one per line (see Expected Output). Test 2 starts empty and printsprocessNext(),size(),pendingPages();then submits memo (2 pages) and printsprocessNext()andsize(): No jobs 0 0 Printed memo (2 pages) 0 Do NOT write a main function.
Expected Output:
12 Printed report (5 pages) 7 1 Printed photo (7 pages) No jobs No jobs 0 0 Printed memo (2 pages) 0
= newline. The output ends with a newline — print one after the last line.
Hints4 available
Sign in to use hintsTopics:
STL ContainersQueues
1
Tab to indent (Esc then Tab to move on) · Ctrl+Enter to run · Shift+Alt+F to format · Ctrl+Space to expand shortcuts (cout, fori)
Your Output
Run your code to see the output here...
Test Cases
Run your code to see test case results.