Re: [Dev-C++] student needs a little help
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Benjamin W. <ben...@ho...> - 2002-02-16 03:56:57
|
<html><div style='background-color:'><P>I would agree with Jason on using a map, but then again...if the assignment is for you to develop a linked list implementation, then you need to research linked lists. You are going to want to have a good grasp of pointers before you start, so if you are rusty on pointers you need to start there.</P> <P>I used to know of a really good sight that explained several interesting data structures, including linked lists, but I cannot find the link right now.</P> <P>I did find this one, that does give some code snippets which should get you started:<BR><A href="http://www.inquiry.com/techtips/cpp_pro/10min/10min0599.asp">http://www.inquiry.com/techtips/cpp_pro/10min/10min0599.asp</A></P> <P>If you need more information, I would recommend going to <A href="http://www.google.com">http://www.google.com</A> and doing a search on linked lists. You'll be amazed at how much is actually out there.</P> <P>Hope that helps you out.</P> <DIV></DIV> <DIV><FONT face="Geneva, Arial, Sans-serif" size=2>Benjamin Wheeless</FONT></DIV> <DIV></DIV> <DIV><FONT face="Geneva, Arial, Sans-serif" size=2><STRONG>Network Systems - Delta Airlines, Inc.</STRONG></FONT></DIV> <DIV></DIV> <DIV><FONT face=Arial size=2><STRONG>Atlanta, GA - USA 30320</STRONG></FONT></DIV> <DIV></DIV> <DIV><FONT face=Arial size=2><STRONG>==============================</STRONG></FONT></DIV> <DIV> </DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>----Original Message Follows---- <DIV></DIV>From: "Jason Hardman" <JAS...@BT...> <DIV></DIV>To: "Dev-C++" <DEV...@LI...> <DIV></DIV>Subject: Re: [Dev-C++] student needs a little help <DIV></DIV>Date: Fri, 15 Feb 2002 23:16:34 -0000 <DIV></DIV> <DIV></DIV>Hi, <DIV></DIV> <DIV></DIV>List structures are usualy taught early on in a programming course you may need to tell your teacher that you haven't yet been taught lists though? You may want to clarify whether you have to make your own list data type or if you can use a standardly available one. C++ defines a standard set of container objects that should be readily available in any up to date C++ distro, called the Standard Template Library (STL), and list is one of them. I would actualy use a map (also available in the STL) to implement the grocery list though. A map is a series <KEY><VALUE>combinations, where you can look up a <VALUE>using the <KEY>part. The STL also defines a range of access and search methods for you. However you may not be allowed to rely on ready made parts, although in the real world you would. <DIV></DIV> <DIV></DIV>My best advise for you would be to arrange to talk to the teacher and ask about these things, because it would take a lot of effort to teach you about lists in a single e-mail. Books usualy have a whole chapter on them and how to use them. Try researching Algorithms and Abstract Data Types. There are probably some web-sites around that cover the subject too, anyone know any? <DIV></DIV> <DIV></DIV>Jason. <DIV></DIV>----- Original Message ----- <DIV></DIV>From: Marton Rusk <DIV></DIV>To: dev...@li... <DIV></DIV>Sent: Friday, February 15, 2002 10:23 PM <DIV></DIV>Subject: [Dev-C++] student needs a little help <DIV></DIV> <DIV></DIV> <DIV></DIV>Hello Everyone, <DIV></DIV> <DIV></DIV>I'm currently a CS Student and need a little help. I have been given the enclosed programming assignment but I'm not sure how to do it. It seems like a simple problem to solve but I don't know how to do list let and from the looks of the problem it will need one. I guess the teacher things we are supposed to know how to do list already. <DIV></DIV> <DIV></DIV>Anyhow, I'd like a few pointers on how to do this problem if possible. Maybe how to do the part of the code where it would require a list and search. <DIV></DIV> <DIV></DIV>Any help is appreciated, thanks. <DIV></DIV> <DIV></DIV>Marton <DIV></DIV> <DIV></DIV> <DIV></DIV>Program #2: Grocery Store Checkout (60 points) <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>Your assignment is to write, run, and test a C++ program, pg2, to simulate the operation of a <DIV></DIV> <DIV></DIV>grocery store checkout system. Your program should first build a data structure to contain <DIV></DIV> <DIV></DIV>information on all the products available in the store. Then the program should print the cash <DIV></DIV> <DIV></DIV>register receipt for each customer. <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>INPUT <DIV></DIV> <DIV></DIV>The input for pg2 has two sources: the inventory information is input from a text file, <DIV></DIV> <DIV></DIV>and the customer transactions are input from the keyboard. <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>1. The information about each product carried by the store is listed on a single line in the <DIV></DIV> <DIV></DIV>inventory file "invent.dat", in the following format: <DIV></DIV> <DIV></DIV><PRODUCT number><DESCRIPTION><PRICE><TAX> <DIV></DIV> <DIV></DIV>where <PRODUCT number>is a five-digit positive (nonzero) integer, <DESCRIPTION>is a string of <DIV></DIV> <DIV></DIV>at most 12 characters with no embedded blanks, <PRICE>is a real number, and <TAX>is a <DIV></DIV> <DIV></DIV>character ('T' if the product is taxable; 'N' if it is not taxable). The data in the inventory file is <DIV></DIV> <DIV></DIV>ordered from smallest to largest product number. <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>2. The customer transactions are input from the keyboard, in the following format: <DIV></DIV> <DIV></DIV><PRODUCT number><TIMES> <DIV></DIV> <DIV></DIV>where <PRODUCT number>is as described above, and <TIMES>is an integer in the range 1 to 100, <DIV></DIV> <DIV></DIV>indicating the quantity of this product desired. A zero input for <PRODUCT number>indicates the <DIV></DIV> <DIV></DIV>end of the customer's order. (The store will soon be using a scanner to input the product number, <DIV></DIV> <DIV></DIV>but for now it is typed in by the cashier.) <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>OUTPUT <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>The program outputs should be written to a text file called "receipts.out", which can be printed <DIV></DIV> <DIV></DIV>out for purposes of determining your grade. <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>1. The inventory information of invent.dat is echo printed to the output file. <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>2. The cash register receipt for each customer is written to the output file. The receipts should be <DIV></DIV> <DIV></DIV>nicely formatted, with the product description (not the product number), number of items, item <DIV></DIV> <DIV></DIV>price, and total price for each product printed on a single line. At the end of each customer's <DIV></DIV> <DIV></DIV>order, the subtotal for all items, amount of tax on taxable items, and total bill should be printed, <DIV></DIV> <DIV></DIV>clearly labeled. (The tax rate is 7.5% for taxable items.) <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>PROCESSING <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>pg2 first reads in all of the inventory information from file invent.dat, echo printing the <DIV></DIV> <DIV></DIV>information to the output file receipts.out. The program then prompts the cashier to begin inputting <DIV></DIV> <DIV></DIV>the order for the first customer. This customer's order is processed, and the receipt is printed to the <DIV></DIV> <DIV></DIV>output file. <DIV></DIV> <DIV></DIV>After each customer's order is processed, the program should ask the cashier if another customer is <DIV></DIV> <DIV></DIV>to be processed. If the answer is 'Y', the program sets up to process the next customer; if the answer <DIV></DIV> <DIV></DIV>is 'N', the program terminates with a friendly message. <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>ERROR CHECKING <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>The following input errors are possible and should be handled by pg2 <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>1. Duplicate <PRODUCT number>in inventory file. Write an error message to the output file and skip <DIV></DIV> <DIV></DIV>the second entry. <DIV></DIV> <DIV></DIV>2. <PRODUCT number>not in inventory file. Write an error message on the receipt, ignore that product <DIV></DIV> <DIV></DIV>number, and continue with the next item. <DIV></DIV> <DIV></DIV>3. <TIMES>not in the specified range. Write an error message to the output file, ignore that line, and <DIV></DIV> <DIV></DIV>continue with the next item. <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>EXAMPLE <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>. From File "Invent.in": <DIV></DIV> <DIV></DIV>11012 gallon-milk 1.99 N <DIV></DIV> <DIV></DIV>11014 butter 2.59 N <DIV></DIV> <DIV></DIV>11110 pie-shells 0.99 N <DIV></DIV> <DIV></DIV>20115 laundry-soap 3.60 T <DIV></DIV> <DIV></DIV>30005 homestyle-br 0.99 N <DIV></DIV> <DIV></DIV>. From keyboard (one customer): <DIV></DIV> <DIV></DIV>11110 2 <DIV></DIV> <DIV></DIV>40012 3 <DIV></DIV> <DIV></DIV>20115 1 <DIV></DIV> <DIV></DIV>0 <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>. To "Receipts.out" file: <DIV></DIV> <DIV></DIV>--------------------------------------------------------- <DIV></DIV> <DIV></DIV>SEP 10, 1998 6:00 pm (* date and time optional *) <DIV></DIV> <DIV></DIV>Customer 1 <DIV></DIV> <DIV></DIV>pie-shells 2 @ 0.99 1.98 <DIV></DIV> <DIV></DIV>*** item 40012 not in inventory *** <DIV></DIV> <DIV></DIV>laundry-soap 1 @ 3.60 3.60 TX <DIV></DIV> <DIV></DIV>Subtotal 5.58 <DIV></DIV> <DIV></DIV>Tax 0.27 <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>Total 5.85 <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>DATA STRUCTURE <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>The inventory information can be stored in a list of product records. Assume that the maximum <DIV></DIV> <DIV></DIV>number of products is 50, for purposes of writing this program. As the data in the inventory file <DIV></DIV> <DIV></DIV>is ordered from smallest to largest product number, it is very simple to insert the product records <DIV></DIV> <DIV></DIV>into this data structure in order. You can use either a sequential or binary search to locate a product <DIV></DIV> <DIV></DIV>number in the inventory. <DIV></DIV> <DIV></DIV>You should specify this data structure as an ADT, as described in the chapter; define and implement <DIV></DIV> <DIV></DIV>a set of operations to encapsulate it. <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>TEST PLAN <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>Be sure to include test cases to test your error conditions in your test plan. <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>DELIVERABLES <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>1. A disk of the source code of the program pg2 and all included files. <DIV></DIV> <DIV></DIV>2. Hard copy of a listing of your implemented test plan. <DIV></DIV> <DIV></DIV>3. Hard copy of the output file, "receipts.out", produced by running your program using the input <DIV></DIV> <DIV></DIV>specified in your test plan. <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV> <DIV></DIV>------------------------------------------------------------------------------ <DIV></DIV>Send and receive Hotmail on your mobile device: Click Here <DIV></DIV>_______________________________________________ Dev-cpp-users mailing list Dev...@li... https://lists.sourceforge.net/lists/listinfo/dev-cpp-users <DIV></DIV></div><br clear=all><hr>Join the worlds largest e-mail service with MSN Hotmail. <a href='http://go.msn.com/bql/hmtag4_etl_EN.asp'>Click Here</a><br></html> |