Question with arrays

Hello. Im taking my first programming class and we have a project involving arrays. These are the concepts that the project wants us to cover.

- Reading data from a file into arrays
- Processing parallel arrays
- Writing array data to files
- Passing arrays to functions
- Processing arrays using various kinds of functions
- Design using a hierarchy chart

I was wondering if there is a place that would give good examples of completed code that i could mess with since i seem to get a better understanding of how things work by being able to mess with a completed code (and my professor is a tool and half the time doesn't even know what she is talking about and then confuses the class). Also with these projects we are restricted to use knowledge from the current chapter and previous chapters (we are in chapter 7 now) in the "STARTING OUT WITH
C++
From Control Structures
through Objects 8th edition" by Tony Gaddis.

Any advice is greatly appreciated.

Ps. this is the entire prompt given to us if you are curious.



Project Description
A small market maintains an inventory of exactly 20 items. You will read these items from a file. Each item named will have an associated cost and a character code to indicate whether or not it is taxable. You will place your online order. A file will contain your "printed" receipt with the total amount of your order.

Project Specifications
Input for this project has two sources. The inventory of exactly 20 items (with cost and tax code for each) is read from an input file. The user must enter: the names of the input and output files, and the items to purchase (by the number code associated with each item.)

Output also has two sources. The command line shows the names of the inventory items, the echo of the chosen item with its price and "taxable" if appropriate. The amount of the tax and the total amount due will appear on the command line screen when the user is finished. The tax rate is 7% (use .07 in your code.) The "printed" receipt will be on the output file. All the non-taxable items should be listed first followed by the taxable items, then the total amount of the tax, and last the total amount due.

Processing Requirements
Create the functions for the following:

1. Read the inventory: Prompt for and get the input file name, open the file, read the items from the file, and store them into the three parallel arrays. The three arrays will be passed as parameters. (NO GLOBAL VARIABLES) Assume that the file contains exactly 20 lines of input and is constructed correctly. Return 0 to the calling function if the file opens, -1 if the file is not found. If the file is not found, do NOT process the grocery order or attempt to write to the output file.
2. Process the grocery order: Assume the user will choose no more than 20 non-taxable items and 20 taxable items. The user enters the code for the item. Validate the item code. Determine from the tax code of ‘N’ or ‘T’ whether to place the item in the non-taxable array(s) or the taxable array(s). Output the amount of the tax and the total amount due for the order. All items used in this function should be passed as parameters. Your last line from this function should be “Thank you for your online order.”
3. Calculate and return the total of array elements. The array and the number of elements in the array should be parameters. This function should be called at least two times.
4. Validate the input item code using a Boolean function (return true or false) from this function.
5. Write the "printed receipt" to the output file: Prompt for and get the output file name, open the file, and output the items, non-taxable items first with the cost of each, then the taxable items with the cost of each and “taxable” in the same line. Print the total amount of the tax, and the total amount due for the order. Your last line should be "Thank you for your on-line order." Your parameters should include all items needed for your “printed receipt.”
Last edited on
This website has some good examples for arrays, or you can google for example: "Read from file into array c++."

Next figure out what all you will need for this project ie what arrays of what type other variables etc.

If you don't understand how to do files, learn that first, they are pretty easy and learning those seems like a big part of the project. Start by reading into your arrays, and outputting them to the console and output file to make sure that you can do all of that correctly.

I know this is vague but this stuff is very important to learn for future projects. Feel free to ask questions on specific parts if need be.
thank you.
Topic archived. No new replies allowed.