Week #1: Data Design and Implementation
Write, run, and test a C++ program to simulate the operation of a grocery store checkout system. Your program should first build a data structure to contain information on all the products available in the store. Then the program should print the cash register receipt for each customer.
The input for this program has two sources: the inventory information is input from a text file, and the customer transactions are input from the keyboard.
1. The information about each product carried by the store is listed on a single line in the inventory file "Invent.dat", in the following format:
<product number> <description> <price> <tax>
where <product number> is a five-digit positive (nonzero) integer, <description> is a string of at most 12 characters with no embedded blanks, <price> is a real number, and <tax> is a character ('T' if the product is taxable; 'N' if it is not taxable). The data in the inventory file is ordered from smallest to largest product number.
2. The customer transactions are input from the keyboard, in the following format:
<product number> <times>
where <product number> is as described above, and <times> is an integer in the range 1 to 100, indicating the quantity of this product desired. A zero input for <product number> indicates the end of the customer's order. (The store will soon be using a scanner to input the product number, but for now it is typed in by the cashier.)
The program outputs should be written to a text file called "Receipts.out".
1. The inventory information is echo printed to the output file.
2. The cash register receipt for each customer is written to the output file. The receipts should be nicely formatted, with the product description (not the product number), number of items, item price, and total price for each product printed on a single line. At the end of each customer's order, the subtotal for all items, amount of tax on taxable items, and total bill should be printed, clearly labeled. (The tax rate is 7.5% for taxable items.)
The program first reads in all of the inventory information from file "Invent.in", echo printing the information to the output file. The program then prompts the cashier to begin inputting the order for the first customer. This customer's order is processed, and the receipt is printed to the output file.
After each customer's order is processed, the program should ask the cashier if another customer is to be processed. If the answer is 'Y', the program sets up to process the next customer; if the answer is 'N', the program terminates with a friendly message.
The following input errors are possible and should be handled by an exception class:
1. Duplicate <product number> in inventory file. Write an error message to the output file and skip the second entry.
2. <Product number> not in inventory file. Write an error message on the receipt, ignore that product number, and continue with the next item.
3. <Times> not in the specified range. Write an error message to the output file, ignore that line, and continue with the next item.
From File "Invent.in":
11012 gallon-milk 1.99 N
11014 butter 2.59 N
11110 pie-shells 0.99 N
20115 laundry-soap 3.60 T
30005 homestyle-br 0.99 N
From keyboard (one customer):
To "Receipts.out" file:
SEP 10, 1998 6:00 pm (* date and time optional *)
pie-shells 2 @ 0.99 1.98
*** item 40012 not in inventory ***
laundry-soap 1 @ 3.60 3.60 TX
Week #2: Sorted and Unsorted Lists
Your assignment is to write a program for a computer dating service. Each client gives you his or her name, phone number, and a list of interests. It is your job to maintain lists of men and women using the service and to match up the compatible couples. You will find more details about the assignment, including the inputs, outputs, and deliverables in the course environment.
Data about current clients should be on file "Clients.mf". For each current client, the file contains the following information:
Sex 1 character, 'M' or 'F'
Name up to 20 characters, followed by comma
Phone Number 8 characters
Number of Interests an integer
List of Interests 10 characters each separated by commas with a period after the final interest.
Match up to 20 characters, followed by end-of-line.
From the keyboard: The user may enter on of the following commands.
NEWCLIENT Add the client to the appropriate list by storing the appropriate information. Attempt to match this new client with a member of the opposite sex. A match occurs when the clients have three or more of the same interests. (You only have to find the first match for each new client.) Make sure you then designate both persons as matched, as described in the section on data structures above. Print the name of the new client, the name of his or her match, and both phone numbers. If no match is found, print an appropriate message.
UNMATCH Unmatch this name with his or her current match by removing from the matched person.
PRINTMATCH Print a list of all matched pairs.
PRINTFREE Print the names and phone numbers of clients who are not currently matched.
QUIT Stop processing
Echo print all screen input and output on file "Dates.out."
Week #3: Stacks & Queues
The local medical clinic has decided to automate its scheduling services. You have been assigned to design the initial version of the schedules. The basic functions that the clinic has in mind are doctor check-in and check-out and patient check-in and check-out.
A doctor checks in by telling the scheduler his or her name, an examination room number, and a medical specialty code. Each doctor has a favorite room. The scheduler checks to see whether the room is free. If so, it assigns this doctor to the room; if not, it rejects the request with a message, and the doctor can try again to check in. When a doctor checks out, the examination room is freed.
A patient checking in gives a name, age, specialist code, and emergency indication. The scheduler tries to match up the patient with a doctor according to a set of rules that are described here. If there is a match, the patient is seen by the assigned doctor. If this doctor is currently seeing a patient, the new patient is queued to see the doctor.
The rules for assigning doctors to patients are as follows:
When a patient checks out, the doctor he or she was assigned to is available to see the next patient, if there is anyone in the waiting list.
Week #4: Lists Plus
List plus Using Visual Studio C++ 2010 Of the three variations of linked lists (circular, with header and trailer nodes, and doubly linked),
which would be most appropriate for each of the following applications and why?
1. You want to search a list for a key and return the keys of the two elements that come
before it and the keys of the two elements that come after it.
2. A text file contains integer elements, one per line, sorted from smallest to larges. You
must read the values from the file and create a sorted linked list containing the values.
3. A list is short and frequently becomes empty. You want a list that is optimal for
inserting an element into the empty list and deleting the last element from the list.
In this assignment, you will use a circular linked list to implement an UnstortedType. You
will find more details about the assignment in the course environment.
Week #5: Programming with Recursion
A toy that many children play with is a base with three pegs and five disks of different diameters. The disks begin on one peg, with the largest disk on the bottom and the other four disks added on in order of size. The idea is to move the disks from the peg they are on to another peg by moving only one disk at a time and without ever putting a larger disk on top of a smaller one. This child's toy is actually an example of a classic mathematical puzzle called the Towers of Hanoi problem.
Write a recursive solution to this problem. It may take you a while to see the solution, but the program itself is quite short.
Week #6: -Binary Search Tree
Your assignment is to write a program for a police department that has collected a database of information on various suspects for a given crime. (Luckily for you, the department is only investigating one crime at a time.) Each suspect has a set of attributes, such as shifty eyes, a limp, or a parrot on his shoulder. The maximum number of such attributes for any suspect is 6. Your program accepts commands to manipulate the database in order to narrow down the list of suspects, in the hope of pinpointing the villain.
1. The retained criminal information, generated by the previous execution of this program, is input from file "Criminal.mf" at the beginning of each inquiry.
2. The user inputs commands from the keyboard, in the format shown below. Names and attributes are strings of no more than 20 characters. The program should not be case sensitive (e.g., 'JOE' and 'Joe' are the same name). To simplify the processing, you can assume that names are unique; that is, no two criminals use the same professional handle. The commands are discussed in detail in the Command Processing instructions below.
1. Responses to user commands are to be written to the screen, as described in the Command Processing instructions below.
2. Echoprint each command and show the results of any PRINT commands in a file called "Criminal.trn". You may determine the format of the information in this file; it should be labeled and formatted clearly. A hard copy of this file is turned in with your program for grading.
3. If any new suspects were added (see ADD command), file "Criminal.mf" must be rewritten to contain the updated collection of criminal information.
New suspects can be added to the collection of criminal information using the ADD command. An inquiry consists of a set of commands with respect to a single crime, at the end of which the crime is assumed to be solved. An inquiry must be completed within the execution of the program; it cannot be "saved" to finish on a subsequent execution. After an inquiry is complete, a new inquiry (the investigation of another crime) can begin. Each new inquiry starts over with the entire collection of suspects. ADD - Add a suspect to the Suspects data structure. Prompt the user for the suspect's name and a list of attributes. ADD commands can be issued only before an inquiry begins.
INQUIRY - Prompt user for code name of this inquiry. Once the inquiry has begun, do not allow the user to issue the ADD command until this inquiry is complete.
TIP - Prompt user for the tip information (a particular attribute). Process the tip, reducing the set of current suspects by deleting suspects who do not match the attribute mentioned in the tip. If there is only one suspect left in the set of active suspects, print out a message indicating that the crime is solved. Be sure to include the suspect's name and inquiry code name. This terminates the current inquiry. (The current inquiry can also be terminated if all suspects have been eliminated. State “all suspects have been eliminate” for the current inquiry.)
CHECK - Prompt the user for a suspect's name. Check the set of active suspects to see if this name is there; print out an appropriate response.
PRINT - Print the set of active suspects (those who have not yet been eliminated).
QUIT - If any new suspects have been added during this execution of the program, rewrite the "Criminal.mf" file. Be careful about how you go about saving the records; the traversal order affects the shape of the tree that is built on the next execution of the program. Terminate the program.
Week #7: Priority Queues, Heaps, Graphs, and Sets
Your assignment is to write and compare two implementations of a priority queue whose highest priority element is the one with the smallest key value. The elements have the following declarations:
Here is A++ solution for this question.
Using Visual Studio (C++ project) to programming.
If you have more question, please contact me via email firstname.lastname@example.org
I will help you any time
Thank you so much