TCSS333 C for System Programming

代写TCSS333留学生作业、代做C/C++编程设计作业、代做Canvas Programming作业、代写C/C++语言作业
TCSS333
C for System Programming
Programming Assignment 5
Using an Array of Nested Struct(s)
DUE: See Canvas Programming Assignment 5 link.
You are to submit a single .c file to Canvas and nothing else (do not zip anything, no Eclipse projects, etc.)
You will be using an array made of nested data structures each of which in c are known as struct.
Your program will read from a single input file (hw5input.txt) and produce 2 output files (hw5Time.txt &
hw5Money.txt). You must name these files exactly this way.
The input file contains a list of items purchased by the customers of a store. Each line looks like this:
Smith 5 sweater $12.50
The line contains
- the name of the customer
- the number of items ordered
- the name of the item
- the price of one item
In the input file, customer purchases are mixed together. For example:
Smith 3 Sweater $22.50
Reich 3 Umbrella $12.50
Smith 1 Microwave $230.00
Lazlo 1 Mirror $60.00
Flintstone 5 Plate $10.00
Lazlo 1 Fridge $1200.00
Stevenson 2 Chair $350.00
Smith 10 Candle $3.50
Stevenson 1 Table $500.00
Flintstone 5 Bowl $7.00
Stevenson 2 Clock $30.00
Lazlo 3 Vase $40.00
Stevenson 1 Couch $800.00
Guidelines:
No more than 20 customers with names no longer than 29 characters.
Customers will purchase no more than 10 items.
Each customer’s order data will be stored as an array element
Each array element contains a customer struct which contains:
Customer Name
Array of items purchased (each element is an item struct)
An item purchased is a struct containing:
The name of the item (no longer than 20 characters)
How many of that item was purchased
The price of one item
Size of the items purchased array
Add more fields to either structure (customer or item) if you need to.
After storing all this data, your program must create two output files, the chronological listing and the financial
listing.
In the chronological listing (saved in file hw5time.txt), you must list every customer in the order in which the
customer first appeared in the input file. For each customer, you must list ordered items in the order in which
those items appeared in the input file. For the example shown above, the output would be (your output
should be formatted exactly as the below output):
Customer: Smith
Orders:
Sweater 3 22.50 67.50
Microwave 1 230.00 230.00
Candle 10 3.50 35.00
Total: 332.50
Customer: Reich
Orders:
Umbrella 3 12.50 37.50
Total: 37.50
Customer: Lazlo
Orders:
Mirror 1 60.00 60.00
Fridge 1 1200.00 1200.00
Vase 3 40.00 120.00
Total: 1380.00
Customer: Flintstone
Orders:
Plate 5 10.00 50.00
Bowl 5 7.00 35.00
Total: 85.00
Customer: Stevenson
Orders:
Chair 2 350.00 700.00
Table 1 500.00 500.00
Clock 2 30.00 60.00
Couch 1 800.00 800.00
Total: 2060.00
Note: Flintstone is the fourth customer because in the input file, he is the fourth customer to be mentioned. The
plate he ordered is listed before the bowl because that is the order of the items in the input file.
In the financial listing (saved in file hw5money.txt), you must list the customers in order of the total value of
their purchases, the largest total value customer appearing first. The items should be listed in order of the
value of each item, the largest value item first. (The value of an item is not the unit price, but the unit price
times the quantity ordered.) Based on the sample data given above and this criteria the output would be:
Stevenson, Total Order = $2060.00
Couch 1 $800.00, Item Value = $800.00
Chair 2 $350.00, Item Value = $700.00
Table 1 $500.00, Item Value = $500.00
Clock 2 $30.00, Item Value = $60.00
Lazlo, Total Order = $1380.00
Fridge 1 $1200.00, Item Value = $1200.00
Vase 3 $40.00, Item Value = $120.00
Mirror 1 $60.00, Item Value = $60.00
Smith, Total Order = $332.50
Microwave 1 $230.00, Item Value = $230.00
Sweater 3 $22.50, Item Value = $67.50
Candle 10 $3.50, Item Value = $35.00
Flintstone, Total Order = $85.00
Plate 5 $10.00, Item Value = $50.00
Bowl 5 $7.00, Item Value = $35.00
Reich, Total Order = $37.50
Umbrella 3 $12.50, Item Value = $37.50
You are expected to decompose your program to at least functions that perform the following tasks:
Read in the data from the input file
Generate the output file named hw5Time.txt (described above)
Sort customers’ items based on total value of the item
Sort customers based on the total value of all purchases
Generate the output file named hw5money.txt (described above)http://www.6daixie.com/contents/13/2104.html

Add other separate functions as you see fit as there are good opportunities to do so. The same rules of good
programming practices required in previous assignments apply here.
In general, you will have a list of customers and each customer will have a list of purchases. As you read
through the input file, you will often need to add another customer to your list of customers. You will also have
to add another item to some customer's list of items. At some point, you will sort all the lists.

因为专业,所以值得信赖。如有需要,请加QQ99515681 或邮箱:[email protected] 

微信:codinghelp

猜你喜欢

转载自www.cnblogs.com/javanewpython/p/9931360.html