Re: [Dev-C++] student needs a little help
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
|
From: Jason H. <jas...@bt...> - 2002-02-15 23:17:12
|
Hi,
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.
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?
Jason.
----- Original Message -----=20
From: Marton Rusk=20
To: dev...@li...=20
Sent: Friday, February 15, 2002 10:23 PM
Subject: [Dev-C++] student needs a little help
Hello Everyone,
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.
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.
Any help is appreciated, thanks.
Marton
Program #2: Grocery Store Checkout (60 points)
=20
Your assignment is to write, run, and test a C++ program, pg2, 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=20
register receipt for each customer.=20
=20
INPUT
The input for pg2 has two sources: the inventory information is input =
from a text file,=20
and the customer transactions are input from the keyboard.
=20
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=20
at most 12 characters with no embedded blanks, <price> is a real =
number, and <tax> is a=20
character ('T' if the product is taxable; 'N' if it is not =
taxable). The data in the inventory file is=20
ordered from smallest to largest product number.
=20
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,=20
indicating the quantity of this product desired. A zero input for =
<product number> indicates the=20
end of the customer's order. (The store will soon be using a =
scanner to input the product number,=20
but for now it is typed in by the cashier.)=20
=20
OUTPUT
=20
The program outputs should be written to a text file called =
"receipts.out", which can be printed
out for purposes of determining your grade.=20
=20
1. The inventory information of invent.dat is echo printed to the =
output file.=20
=20
2. The cash register receipt for each customer is written to the =
output file. The receipts should be=20
nicely formatted, with the product description (not the product =
number), number of items, item=20
price, and total price for each product printed on a single line. =
At the end of each customer's=20
order, the subtotal for all items, amount of tax on taxable items, =
and total bill should be printed,=20
clearly labeled. (The tax rate is 7.5% for taxable items.)=20
=20
PROCESSING
=20
pg2 first reads in all of the inventory information from file =
invent.dat, echo printing the=20
information to the output file receipts.out. The program then prompts =
the cashier to begin inputting=20
the order for the first customer. This customer's order is processed, =
and the receipt is printed to the=20
output file.
After each customer's order is processed, the program should ask the =
cashier if another customer is=20
to be processed. If the answer is 'Y', the program sets up to process =
the next customer; if the answer=20
is 'N', the program terminates with a friendly message.=20
=20
ERROR CHECKING
=20
The following input errors are possible and should be handled by pg2
=20
1. Duplicate <product number> in inventory file. Write an error =
message to the output file and skip=20
the second entry.=20
2. <Product number> not in inventory file. Write an error message on =
the receipt, ignore that product=20
number, and continue with the next item.=20
3. <Times> not in the specified range. Write an error message to the =
output file, ignore that line, and=20
continue with the next item.=20
=20
EXAMPLE
. 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):
11110 2
40012 3
20115 1
0
=20
. To "Receipts.out" file:
---------------------------------------------------------
SEP 10, 1998 6:00 pm (* date and time optional *)
Customer 1
pie-shells 2 @ 0.99 1.98
*** item 40012 not in inventory ***
laundry-soap 1 @ 3.60 3.60 TX
Subtotal 5.58
Tax 0.27
=20
Total 5.85=20
=20
=20
DATA STRUCTURE
=20
The inventory information can be stored in a list of product records. =
Assume that the maximum=20
number of products is 50, for purposes of writing this program. As the =
data in the inventory file=20
is ordered from smallest to largest product number, it is very simple =
to insert the product records=20
into this data structure in order. You can use either a sequential or =
binary search to locate a product=20
number in the inventory.
You should specify this data structure as an ADT, as described in the =
chapter; define and implement=20
a set of operations to encapsulate it.=20
=20
=20
TEST PLAN
=20
Be sure to include test cases to test your error conditions in your =
test plan.=20
=20
DELIVERABLES
=20
1. A disk of the source code of the program pg2 and all included =
files.=20
2. Hard copy of a listing of your implemented test plan.
3. Hard copy of the output file, "receipts.out", produced by running =
your program using the input=20
specified in your test plan.
-------------------------------------------------------------------------=
-----
Send and receive Hotmail on your mobile device: Click Here
_______________________________________________ Dev-cpp-users mailing =
list Dev...@li... =
https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
|