Homework 1 - Structures
Due: Tuesday, January 19, 2009 at 5:00pm
Coding Conventions
The following coding conventions should be used for all assignments.
Assignment
The purpose of this assignment is to create a structure called ProductInfo
for a small inventory control system. You will also be using a dynamic array
to track the collection of products in the inventory. You MUST use a dynamic
array for this assignment. Any assignment that does not use new/delete will
have points deducted.
The ProductInfo structure must have the following pieces of data:
- A C-style string for the product name (you may choose the length for this string)
- A C-style string for the product description (you may choose the length for this string)
- A 13 character C-style string for the UPC (Universal Product Code)
- An integer for how many of that product are in stock
You will have the following two void functions to manipulate ProductInfo objects:
- addProduct - Takes a single ProductInfo object as a parameter. It will set
the name, description, UPC and amount in stock for that product by prompting
the user for this information.
- showProduct - Takes a single ProductInfo object as a parameter. It will
display the name, description, UPC and amount in stock for that product.
Your main function will do the following steps:
- Prompt the user for the number of products they wish to add to the
inventory and read the response in.
- Validate that the integer given by the user is greater than 0. Points will
be deducted if you do not validate the user's input.
- Dynamically allocate an array of ProductInfo objects using the integer
given by the user.
- For each object in the ProductInfo array, call addProduct.
- For each object in the ProductInfo array, call showProduct.
- Deallocate the array.
Email your source code to me by the due date.