CMSC 201
Programming Project Three

The CSEE Book Store

Out: Thursday 10/25/07
Due: Before Midnight, Sunday 11/11/07

The design document for this project, design3.txt
is due: Before Midnight, Sunday 11/4/07

The Objective

The objective of this assignment is to give you experience working with pointers and arrays of structures. You'll be doing file handling, dynamically allocating an array of structures, and using passing by reference. Good program design and implementation techniques are expected, as well as separate compilation.

The Background

The CSEE Book Store offers students a selection of Computer Science textbooks that are required or recommended for many of the CMSC courses. The store keeps track of the books in inventory with an inventory file. A student can use the order system to purchase single or multiple copies of the books available. The system creates an invoice for the student and also removes the books ordered from the inventory.

The Task

Design and code a project that after printing a greeting and getting the name of the inventory file from the user, presents the user with a list of the book titles found in that file and the specific CMSC courses they are required or recommended for. The books are listed in order of their inventory numbers.

The user can then choose to see more information about one of the books by entering its inventory number or may choose to quit. If the user chooses to see more information about a book, in addition to the title, s/he is shown the isbn number, author, publisher, the price per copy and the number of copies in stock. The user will then enter the number of copies s/he wants to order (0 is a possibility).

Once the user has entered the number of copies to order, which is not 0, a line item is generated and written on the invoice and the inventory is decreased by that number of copies. The user is then presented with the list of titles again, so that further selections can be ordered.

When the user has finished ordering books, the invoice is completed by showing the subtotal, adding the sales tax (5% of the subtotal) and writing the tax and total. A new inventory file is then produced which is to be formatted exactly like the original inventory file, but with the number of copies adjusted to reflect the books bought on the order.

Sample Run

linux2[102]% ls a.out bookstore.h inventory.dat proj3.o bookstore.c bookstore.o proj3.c linux2[103]% a.out Your greeting and instructions go here Enter the name of the inventory file : inventory.dat 1 - The_C_Programming_Language CMSC 201 - Recommended 2 - Learning_the_UNIX_Operating_System CMSC 201 - Recommended 3 - Absolute_Java CMSC 202 - Required 4 - Head_First_Java CMSC 202 - Recommended 5 - Discrete_Mathematics_and_Its_Applications CMSC 203 - Required 6 - Concepts_of_Programming_Languages CMSC 331 - Required 7 - Data_Structures_&_Algorithm_Analysis_in_Java CMSC 341 - Required 8 - Computer_Organization_and_Design CMSC 411 - Required 9 - Operating_System_Concepts CMSC 421 - Required 10 - Fundamentals_of_Computer_Graphics CMSC 435 - Required 11 - Open_GL_Programming_Guide CMSC 435 - Recommended 12 - Database_System_Concepts CMSC 461 - Required 13 - Computer_Networks CMSC 481 - Required 14 - More_Servlets_&_Java_Server_Pages CMSC 484 - Required 15 - Getting_What-You_Came_For CMSC 601 - Required 16 - Writing_for_Computer_Science CMSC 601 - Required 17 - Real-Time_Rendering CMSC 635 - Required 18 - Introduction_to_Algorithms CMSC 641 - Required 19 - Database_Systems:_The_Complete_Book CMSC 661 - Required To view a book's information enter its number or -1 to quit : 0 To view a book's information enter its number or -1 to quit : -5 To view a book's information enter its number or -1 to quit : 20 To view a book's information enter its number or -1 to quit : 5 Inventory #: 5 ISBN: 978-0073312712 Title: Discrete_Mathematics_and_Its_Applications Author: Kenneth_Rosen Publisher: McGraw_Hill Price: $ 117.58 Number of copies available: 40 How many would you like to order ? Please enter an integer between 0 and 40 : 0 1 - The_C_Programming_Language CMSC 201 - Recommended 2 - Learning_the_UNIX_Operating_System CMSC 201 - Recommended 3 - Absolute_Java CMSC 202 - Required 4 - Head_First_Java CMSC 202 - Recommended 5 - Discrete_Mathematics_and_Its_Applications CMSC 203 - Required 6 - Concepts_of_Programming_Languages CMSC 331 - Required 7 - Data_Structures_&_Algorithm_Analysis_in_Java CMSC 341 - Required 8 - Computer_Organization_and_Design CMSC 411 - Required 9 - Operating_System_Concepts CMSC 421 - Required 10 - Fundamentals_of_Computer_Graphics CMSC 435 - Required 11 - Open_GL_Programming_Guide CMSC 435 - Recommended 12 - Database_System_Concepts CMSC 461 - Required 13 - Computer_Networks CMSC 481 - Required 14 - More_Servlets_&_Java_Server_Pages CMSC 484 - Required 15 - Getting_What-You_Came_For CMSC 601 - Required 16 - Writing_for_Computer_Science CMSC 601 - Required 17 - Real-Time_Rendering CMSC 635 - Required 18 - Introduction_to_Algorithms CMSC 641 - Required 19 - Database_Systems:_The_Complete_Book CMSC 661 - Required To view a book's information enter its number or -1 to quit : -1 To view the invoice type more invoice.txt at the Linux prompt linux2[104]% more invoice.txt invoice.txt: No such file or directory linux2[105]% ls a.out bookstore.h inventory.dat proj3.c bookstore.c bookstore.o newInventory.dat proj3.o linux2[106]% a.out Your greeting and instructions go here Enter the name of the inventory file : inventory.dat 1 - The_C_Programming_Language CMSC 201 - Recommended 2 - Learning_the_UNIX_Operating_System CMSC 201 - Recommended 3 - Absolute_Java CMSC 202 - Required 4 - Head_First_Java CMSC 202 - Recommended 5 - Discrete_Mathematics_and_Its_Applications CMSC 203 - Required 6 - Concepts_of_Programming_Languages CMSC 331 - Required 7 - Data_Structures_&_Algorithm_Analysis_in_Java CMSC 341 - Required 8 - Computer_Organization_and_Design CMSC 411 - Required 9 - Operating_System_Concepts CMSC 421 - Required 10 - Fundamentals_of_Computer_Graphics CMSC 435 - Required 11 - Open_GL_Programming_Guide CMSC 435 - Recommended 12 - Database_System_Concepts CMSC 461 - Required 13 - Computer_Networks CMSC 481 - Required 14 - More_Servlets_&_Java_Server_Pages CMSC 484 - Required 15 - Getting_What-You_Came_For CMSC 601 - Required 16 - Writing_for_Computer_Science CMSC 601 - Required 17 - Real-Time_Rendering CMSC 635 - Required 18 - Introduction_to_Algorithms CMSC 641 - Required 19 - Database_Systems:_The_Complete_Book CMSC 661 - Required To view a book's information enter its number or -1 to quit : 8 Inventory #: 8 ISBN: 978-0-12-370606-5 Title: Computer_Organization_and_Design Author: Patterson_&_Hennessy Publisher: Morgan_Kaufmann Price: $ 64.95 Number of copies available: 120 How many would you like to order ? Please enter an integer between 0 and 120 : 5 1 - The_C_Programming_Language CMSC 201 - Recommended 2 - Learning_the_UNIX_Operating_System CMSC 201 - Recommended 3 - Absolute_Java CMSC 202 - Required 4 - Head_First_Java CMSC 202 - Recommended 5 - Discrete_Mathematics_and_Its_Applications CMSC 203 - Required 6 - Concepts_of_Programming_Languages CMSC 331 - Required 7 - Data_Structures_&_Algorithm_Analysis_in_Java CMSC 341 - Required 8 - Computer_Organization_and_Design CMSC 411 - Required 9 - Operating_System_Concepts CMSC 421 - Required 10 - Fundamentals_of_Computer_Graphics CMSC 435 - Required 11 - Open_GL_Programming_Guide CMSC 435 - Recommended 12 - Database_System_Concepts CMSC 461 - Required 13 - Computer_Networks CMSC 481 - Required 14 - More_Servlets_&_Java_Server_Pages CMSC 484 - Required 15 - Getting_What-You_Came_For CMSC 601 - Required 16 - Writing_for_Computer_Science CMSC 601 - Required 17 - Real-Time_Rendering CMSC 635 - Required 18 - Introduction_to_Algorithms CMSC 641 - Required 19 - Database_Systems:_The_Complete_Book CMSC 661 - Required To view a book's information enter its number or -1 to quit : 10 Inventory #: 10 ISBN: 978-1-56881-269-4 Title: Fundamentals_of_Computer_Graphics Author: Peter_Shirley Publisher: A_K_Peters Price: $ 70.30 Number of copies available: 40 How many would you like to order ? Please enter an integer between 0 and 40 : 1 1 - The_C_Programming_Language CMSC 201 - Recommended 2 - Learning_the_UNIX_Operating_System CMSC 201 - Recommended 3 - Absolute_Java CMSC 202 - Required 4 - Head_First_Java CMSC 202 - Recommended 5 - Discrete_Mathematics_and_Its_Applications CMSC 203 - Required 6 - Concepts_of_Programming_Languages CMSC 331 - Required 7 - Data_Structures_&_Algorithm_Analysis_in_Java CMSC 341 - Required 8 - Computer_Organization_and_Design CMSC 411 - Required 9 - Operating_System_Concepts CMSC 421 - Required 10 - Fundamentals_of_Computer_Graphics CMSC 435 - Required 11 - Open_GL_Programming_Guide CMSC 435 - Recommended 12 - Database_System_Concepts CMSC 461 - Required 13 - Computer_Networks CMSC 481 - Required 14 - More_Servlets_&_Java_Server_Pages CMSC 484 - Required 15 - Getting_What-You_Came_For CMSC 601 - Required 16 - Writing_for_Computer_Science CMSC 601 - Required 17 - Real-Time_Rendering CMSC 635 - Required 18 - Introduction_to_Algorithms CMSC 641 - Required 19 - Database_Systems:_The_Complete_Book CMSC 661 - Required To view a book's information enter its number or -1 to quit : 5 Inventory #: 5 ISBN: 978-0073312712 Title: Discrete_Mathematics_and_Its_Applications Author: Kenneth_Rosen Publisher: McGraw_Hill Price: $ 117.58 Number of copies available: 40 How many would you like to order ? Please enter an integer between 0 and 40 : 0 1 - The_C_Programming_Language CMSC 201 - Recommended 2 - Learning_the_UNIX_Operating_System CMSC 201 - Recommended 3 - Absolute_Java CMSC 202 - Required 4 - Head_First_Java CMSC 202 - Recommended 5 - Discrete_Mathematics_and_Its_Applications CMSC 203 - Required 6 - Concepts_of_Programming_Languages CMSC 331 - Required 7 - Data_Structures_&_Algorithm_Analysis_in_Java CMSC 341 - Required 8 - Computer_Organization_and_Design CMSC 411 - Required 9 - Operating_System_Concepts CMSC 421 - Required 10 - Fundamentals_of_Computer_Graphics CMSC 435 - Required 11 - Open_GL_Programming_Guide CMSC 435 - Recommended 12 - Database_System_Concepts CMSC 461 - Required 13 - Computer_Networks CMSC 481 - Required 14 - More_Servlets_&_Java_Server_Pages CMSC 484 - Required 15 - Getting_What-You_Came_For CMSC 601 - Required 16 - Writing_for_Computer_Science CMSC 601 - Required 17 - Real-Time_Rendering CMSC 635 - Required 18 - Introduction_to_Algorithms CMSC 641 - Required 19 - Database_Systems:_The_Complete_Book CMSC 661 - Required To view a book's information enter its number or -1 to quit : 11 Inventory #: 11 ISBN: 978-0321481009 Title: Open_GL_Programming_Guide Author: Shreiner,_Woo,_Neider,_Davis Publisher: Addison_Wesley Price: $ 59.99 Number of copies available: 35 How many would you like to order ? Please enter an integer between 0 and 35 : 1 1 - The_C_Programming_Language CMSC 201 - Recommended 2 - Learning_the_UNIX_Operating_System CMSC 201 - Recommended 3 - Absolute_Java CMSC 202 - Required 4 - Head_First_Java CMSC 202 - Recommended 5 - Discrete_Mathematics_and_Its_Applications CMSC 203 - Required 6 - Concepts_of_Programming_Languages CMSC 331 - Required 7 - Data_Structures_&_Algorithm_Analysis_in_Java CMSC 341 - Required 8 - Computer_Organization_and_Design CMSC 411 - Required 9 - Operating_System_Concepts CMSC 421 - Required 10 - Fundamentals_of_Computer_Graphics CMSC 435 - Required 11 - Open_GL_Programming_Guide CMSC 435 - Recommended 12 - Database_System_Concepts CMSC 461 - Required 13 - Computer_Networks CMSC 481 - Required 14 - More_Servlets_&_Java_Server_Pages CMSC 484 - Required 15 - Getting_What-You_Came_For CMSC 601 - Required 16 - Writing_for_Computer_Science CMSC 601 - Required 17 - Real-Time_Rendering CMSC 635 - Required 18 - Introduction_to_Algorithms CMSC 641 - Required 19 - Database_Systems:_The_Complete_Book CMSC 661 - Required To view a book's information enter its number or -1 to quit : 12 Inventory #: 12 ISBN: 978-0072958867 Title: Database_System_Concepts Author: Siberschatz,_Korth,_Sudershan Publisher: McGraw_Hill Price: $ 122.02 Number of copies available: 50 How many would you like to order ? Please enter an integer between 0 and 50 : 2 1 - The_C_Programming_Language CMSC 201 - Recommended 2 - Learning_the_UNIX_Operating_System CMSC 201 - Recommended 3 - Absolute_Java CMSC 202 - Required 4 - Head_First_Java CMSC 202 - Recommended 5 - Discrete_Mathematics_and_Its_Applications CMSC 203 - Required 6 - Concepts_of_Programming_Languages CMSC 331 - Required 7 - Data_Structures_&_Algorithm_Analysis_in_Java CMSC 341 - Required 8 - Computer_Organization_and_Design CMSC 411 - Required 9 - Operating_System_Concepts CMSC 421 - Required 10 - Fundamentals_of_Computer_Graphics CMSC 435 - Required 11 - Open_GL_Programming_Guide CMSC 435 - Recommended 12 - Database_System_Concepts CMSC 461 - Required 13 - Computer_Networks CMSC 481 - Required 14 - More_Servlets_&_Java_Server_Pages CMSC 484 - Required 15 - Getting_What-You_Came_For CMSC 601 - Required 16 - Writing_for_Computer_Science CMSC 601 - Required 17 - Real-Time_Rendering CMSC 635 - Required 18 - Introduction_to_Algorithms CMSC 641 - Required 19 - Database_Systems:_The_Complete_Book CMSC 661 - Required To view a book's information enter its number or -1 to quit : 14 Inventory #: 14 ISBN: 978-0130676144 Title: More_Servlets_&_Java_Server_Pages Author: Marty_Hall Publisher: Prentice_Hall Price: $ 37.79 Number of copies available: 40 How many would you like to order ? Please enter an integer between 0 and 40 : 3 1 - The_C_Programming_Language CMSC 201 - Recommended 2 - Learning_the_UNIX_Operating_System CMSC 201 - Recommended 3 - Absolute_Java CMSC 202 - Required 4 - Head_First_Java CMSC 202 - Recommended 5 - Discrete_Mathematics_and_Its_Applications CMSC 203 - Required 6 - Concepts_of_Programming_Languages CMSC 331 - Required 7 - Data_Structures_&_Algorithm_Analysis_in_Java CMSC 341 - Required 8 - Computer_Organization_and_Design CMSC 411 - Required 9 - Operating_System_Concepts CMSC 421 - Required 10 - Fundamentals_of_Computer_Graphics CMSC 435 - Required 11 - Open_GL_Programming_Guide CMSC 435 - Recommended 12 - Database_System_Concepts CMSC 461 - Required 13 - Computer_Networks CMSC 481 - Required 14 - More_Servlets_&_Java_Server_Pages CMSC 484 - Required 15 - Getting_What-You_Came_For CMSC 601 - Required 16 - Writing_for_Computer_Science CMSC 601 - Required 17 - Real-Time_Rendering CMSC 635 - Required 18 - Introduction_to_Algorithms CMSC 641 - Required 19 - Database_Systems:_The_Complete_Book CMSC 661 - Required To view a book's information enter its number or -1 to quit : -1 To view the invoice type more invoice.txt at the Linux prompt linux2[107]% more invoice.txt Title Qty Unit Price Computer_Organization_and_Design 5 @ 64.95 324.75 Fundamentals_of_Computer_Graphics 1 @ 70.30 70.30 Open_GL_Programming_Guide 1 @ 59.99 59.99 Database_System_Concepts 2 @ 122.02 244.04 More_Servlets_&_Java_Server_Pages 3 @ 37.79 113.37 ---------------------------------------------------------------------------- Subtotal 812.45 Sales Tax 40.62 ----------------------- Total $ 853.07 linux2[108]% cat inventory.dat 19 1 201 0 0-13-110362-8 The_C_Programming_Language Kernighan_&_Ritchie Prentice_Hall 37.48 150 2 201 0 0-59-600261-0 Learning_the_UNIX_Operating_System Peak,_Todino-Gonquet_&_Strang O'Reilly 13.57 150 3 202 1 978-0321487926 Absolute_Java Savitch Addison_Wesley 107.40 200 4 202 0 978-0596009205 Head_First_Java Sierra_&_Bates O'Reilly 29.67 100 5 203 1 978-0073312712 Discrete_Mathematics_and_Its_Applications Kenneth_Rosen McGraw_Hill 117.58 40 6 331 1 978-0321493620 Concepts_of_Programming_Languages Robert_Sebesta Addison_Wesley 109.40 50 7 341 1 978-0321370136 Data_Structures_&_Algorithm_Analysis_in_Java Mark_Weiss Addison_Wesley 100.60 120 8 411 1 978-0-12-370606-5 Computer_Organization_and_Design Patterson_&_Hennessy Morgan_Kaufmann 64.95 120 9 421 1 978-0471694663 Operating_System_Concepts Silberschatz,_Galvin,_Gagne Wiley 85.83 120 10 435 1 978-1-56881-269-4 Fundamentals_of_Computer_Graphics Peter_Shirley A_K_Peters 70.30 40 11 435 0 978-0321481009 Open_GL_Programming_Guide Shreiner,_Woo,_Neider,_Davis Addison_Wesley 59.99 35 12 461 1 978-0072958867 Database_System_Concepts Siberschatz,_Korth,_Sudershan McGraw_Hill 122.02 50 13 481 1 978-0130661029 Computer_Networks Tanenbaum Prentice_Hall 73.44 40 14 484 1 978-0130676144 More_Servlets_&_Java_Server_Pages Marty_Hall Prentice_Hall 37.79 40 15 601 1 0-374-52477-7 Getting_What-You_Came_For Robert_Peters Farrer_&_Straus 10.88 20 16 601 1 978-1852338022 Writing_for_Computer_Science Justin_Zobel Springer 29.95 20 17 635 1 978-1-56881-182-6 Real-Time_Rendering Akenine-Moller_&_Haines A_K_Peters 53.76 40 18 641 1 978-0072970548 Introduction_to_Algorithms Cormen,_Leiserson,_Rivest_&_Stein McGraw_Hill 107.27 40 19 661 1 978-0130319951 Database_Systems:_The_Complete_Book Molina,_Ullman,_Widom Prentice_Hall 94.02 40 linux2[109]% cat newInventory.dat 19 1 201 0 0-13-110362-8 The_C_Programming_Language Kernighan_&_Ritchie Prentice_Hall 37.48 150 2 201 0 0-59-600261-0 Learning_the_UNIX_Operating_System Peak,_Todino-Gonquet_&_Strang O'Reilly 13.57 150 3 202 1 978-0321487926 Absolute_Java Savitch Addison_Wesley 107.40 200 4 202 0 978-0596009205 Head_First_Java Sierra_&_Bates O'Reilly 29.67 100 5 203 1 978-0073312712 Discrete_Mathematics_and_Its_Applications Kenneth_Rosen McGraw_Hill 117.58 40 6 331 1 978-0321493620 Concepts_of_Programming_Languages Robert_Sebesta Addison_Wesley 109.40 50 7 341 1 978-0321370136 Data_Structures_&_Algorithm_Analysis_in_Java Mark_Weiss Addison_Wesley 100.60 120 8 411 1 978-0-12-370606-5 Computer_Organization_and_Design Patterson_&_Hennessy Morgan_Kaufmann 64.95 115 9 421 1 978-0471694663 Operating_System_Concepts Silberschatz,_Galvin,_Gagne Wiley 85.83 120 10 435 1 978-1-56881-269-4 Fundamentals_of_Computer_Graphics Peter_Shirley A_K_Peters 70.30 39 11 435 0 978-0321481009 Open_GL_Programming_Guide Shreiner,_Woo,_Neider,_Davis Addison_Wesley 59.99 34 12 461 1 978-0072958867 Database_System_Concepts Siberschatz,_Korth,_Sudershan McGraw_Hill 122.02 48 13 481 1 978-0130661029 Computer_Networks Tanenbaum Prentice_Hall 73.44 40 14 484 1 978-0130676144 More_Servlets_&_Java_Server_Pages Marty_Hall Prentice_Hall 37.79 37 15 601 1 0-374-52477-7 Getting_What-You_Came_For Robert_Peters Farrer_&_Straus 10.88 20 16 601 1 978-1852338022 Writing_for_Computer_Science Justin_Zobel Springer 29.95 20 17 635 1 978-1-56881-182-6 Real-Time_Rendering Akenine-Moller_&_Haines A_K_Peters 53.76 40 18 641 1 978-0072970548 Introduction_to_Algorithms Cormen,_Leiserson,_Rivest_&_Stein McGraw_Hill 107.27 40 19 661 1 978-0130319951 Database_Systems:_The_Complete_Book Molina,_Ullman,_Widom Prentice_Hall 94.02 40 linux2[110]%

Although your output need not be identical to the above, all information (including the greeting) must be present.

Please be aware that this is definitely NOT a complete test of the program. Your testing should be much more extensive.

Input Guarantees

Further Specifications

Submitting the Program

Here is a sample submission command. Since you may have different file names you'll have to adjust it to fit your needs. As always, be sure to submit all of the files necessary for your project to compile.
Note that the project name starts with uppercase 'P'.

submit cs201 Proj3 proj3.c bookstore.c bookstore.h

To verify that your project was submitted, you can execute the following command at the Unix prompt. It will show the file that you submitted in a format similar to the Unix 'ls' command.

submitls cs201 Proj3