IntroductionWrite a program that simulates managing jobs sent to a printer. The jobs are stored in a linked-list of pointers. Print jobs arrive at time specified by month/day/year plus hour/minute. The jobs are printed on a first come first serve basis. Here is the rest of the specification.Your solutionWrite a C++ program that has the following and does the following:• Write a struct that will represent a node in the linked list (This struct should be declared outside the LinkedLisst class). The data members of the struct should be:a) sequence number: type integerb) document_name: type stringc) month: type integerd) day: type integere) year: type integerf) hour: type integerg) minute: type integerh) owner: type stringi) service_required: type stringj) next: pointer to a node • Write a class whose data members are a head pointer to a node and a pointer to the last node. DO NOT USE C++11 STL containers such as list, dequeuer, queue, stack. The head will represent the start of a linked list. The member functions are specified below (define all member functions outside class).(a) Constuctor: set the pointers to null(b) InsertNode: When a job has just been sent to the printer, allocate memory for a new node (using the struct) and assign details received in parameters to the new node. The first node will be given sequence number 1, and subsequent nodes will have sequence numbers in increments of 1. You may make the new node the new head.(c) DeleteNode: A print job may be cancelled before being printed. This method should receive the name of the job as a parameter and call the SearchNode function to find the node of the print job. Delete the node by putting its next pointer into the previous node next pointer.(d) SearchNode: This function receives the job name as parameters. Use a loop to process the list to find the job. Return the pointer to the current node when found or null when end of list is reached.(e) PrintDocument: get the job at the tail-end of the list and assign null to the previous next pointer. Display a message saying the job (give details at the node) has been printed. Return the pointer to the tail job.(f) ListAll: use a while loop to go through the linked list from beginning to end displaying line:N Job-name MM/DD/YYYY HH:MM XXXXXXXwhere N is the sequence number, Job-name is the name of the document, MM/DD/YYY is the date from the date members of the struct, HH:MM is the time from the time data members, and XXXXXX is the name of the user who sent this job to be printed.Return the number of nodes in the linked list.(g) Destructor: use a while loop to go through the list and delete the nodes. (Do not delete a note before saving the next pointer on the node).   • The main() function: Write a main function that instantiates an object using the linked list class. The main function should have a do ... while ... loop that runs until quit is selected and offers the user the following menu:1) New print job2) Print a document3) Cancel a print request – remove from print job list4) List all documents waiting to be printed5) QuitNext (still in the loop), an option made by the user should be input. Depending on the option selected by the user, one of the operations listed in the bulleted list below should be performed. You may use a switch statement to handle this selection.• New document sent to the printer: input the name, date, time, and username. The member function of the class that inserts a node is then called passing the name, date, time, and username as arguments (parameters).• Print a document: when this option is selected, call the PrintDocument member function of the class.• Cancel a print request: when this option is selected, input the name of the document to be cancelled. This should be passed to the DeleteNode function of the class and the node should be deleted when found. The function should return the status of the delete. If the print job was found, display a message stating that “the document removed and was not printed”. If the document was not found display a message that “probably too late, the document was already printed”.• List all: First display the following table headings:CLASSROOM BUILDING 222 PRINTER - DOCUMENTS WAITING FOR PRINTINGSEQUENCE NAME ARRIVAL DATE/TIME OWNERNext, call the ListAll member function of the object putting it on the right of an assignment to an integer to receive the returned number of nodes in the list.Display a message:There are NN documents waiting to be printed.Where NN is an integer.

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter17: Linked Lists
Section: Chapter Questions
Problem 18SA
icon
Related questions
Question

Introduction
Write a program that simulates managing jobs sent to a printer. The jobs are stored in a linked-list of pointers. Print jobs arrive at time specified by month/day/year plus hour/minute. The jobs are printed on a first come first serve basis. Here is the rest of the specification.
Your solution
Write a C++ program that has the following and does the following:
• Write a struct that will represent a node in the linked list (This struct should be declared outside the LinkedLisst class). The data members of the struct should be:
a) sequence number: type integer
b) document_name: type string
c) month: type integer
d) day: type integer
e) year: type integer
f) hour: type integer
g) minute: type integer
h) owner: type string
i) service_required: type string
j) next: pointer to a node

• Write a class whose data members are a head pointer to a node and a pointer to the last node. DO NOT USE C++11 STL containers such as list, dequeuer, queue, stack. The head will represent the start of a linked list. The member functions are specified below (define all member functions outside class).
(a) Constuctor: set the pointers to null
(b) InsertNode: When a job has just been sent to the printer, allocate memory for a new node (using the struct) and assign details received in parameters to the new node. The first node will be given sequence number 1, and subsequent nodes will have sequence numbers in increments of 1. You may make the new node the new head.
(c) DeleteNode: A print job may be cancelled before being printed. This method should receive the name of the job as a parameter and call the SearchNode function to find the node of the print job. Delete the node by putting its next pointer into the previous node next pointer.
(d) SearchNode: This function receives the job name as parameters. Use a loop to process the list to find the job. Return the pointer to the current node when found or null when end of list is reached.
(e) PrintDocument: get the job at the tail-end of the list and assign null to the previous next pointer. Display a message saying the job (give details at the node) has been printed. Return the pointer to the tail job.
(f) ListAll: use a while loop to go through the linked list from beginning to end displaying line:
N Job-name MM/DD/YYYY HH:MM XXXXXXX
where N is the sequence number, Job-name is the name of the document, MM/DD/YYY is the date from the date members of the struct, HH:MM is the time from the time data members, and XXXXXX is the name of the user who sent this job to be printed.
Return the number of nodes in the linked list.
(g) Destructor: use a while loop to go through the list and delete the nodes. (Do not delete a note before saving the next pointer on the node).

 

• The main() function: Write a main function that instantiates an object using the linked list class. The main function should have a do ... while ... loop that runs until quit is selected and offers the user the following menu:
1) New print job
2) Print a document
3) Cancel a print request – remove from print job list
4) List all documents waiting to be printed
5) Quit
Next (still in the loop), an option made by the user should be input. Depending on the option selected by the user, one of the operations listed in the bulleted list below should be performed. You may use a switch statement to handle this selection.
• New document sent to the printer: input the name, date, time, and username. The member function of the class that inserts a node is then called passing the name, date, time, and username as arguments (parameters).
• Print a document: when this option is selected, call the PrintDocument member function of the class.
• Cancel a print request: when this option is selected, input the name of the document to be cancelled. This should be passed to the DeleteNode function of the class and the node should be deleted when found. The function should return the status of the delete. If the print job was found, display a message stating that “the document removed and was not printed”. If the document was not found display a message that “probably too late, the document was already printed”.
• List all: First display the following table headings:
CLASSROOM BUILDING 222 PRINTER - DOCUMENTS WAITING FOR PRINTING
SEQUENCE NAME ARRIVAL DATE/TIME OWNER
Next, call the ListAll member function of the object putting it on the right of an assignment to an integer to receive the returned number of nodes in the list.
Display a message:
There are NN documents waiting to be printed.
Where NN is an integer.

 

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 2 images

Blurred answer
Knowledge Booster
Lists
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning