CJCoding With Joseph
15free / daySign inCreate account

Printer Job Scheduler

Build a class PrintQueue that serves print jobs first-come, first-served, storing each job's name and page count in a queue.

Methods:
- void submit(const string& name, int pages): adds a job to the back.
- string processNext(): removes the front job and returns Printed NAME (P pages), e.g. Printed report (5 pages). With no jobs, returns No jobs and 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 prints pendingPages(), processNext(), pendingPages(), size(), processNext(), processNext(), one per line (see Expected Output).

Test 2 starts empty and prints processNext(), size(), pendingPages(); then submits memo (2 pages) and prints processNext() and size():
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
Topics:
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.