In this Individual Project, you will continue working on your application. In Week 4, you used 2 arrays to represent the list of products and their quantities. Memory needs were determined before program execution. This week, you will use dynamic allocation so the memory needs are determined during runtime. The functionality of the program is not expected to change. You also need to update the project document by explaining the changes implemented, and discuss how using dynamic memory allocation changed your application structure.

The Application

  • Design the solution.
  • For the quantities, use a pointer to the first item of an array of int. An example of the declaration code may look like the following:
int * numbers;
numbers = new int [n];
  • For the products, use an array of pointers to strings, and dynamically allocate space for each of the strings. An example of the declaration code may look like the following:
char Temp[100]; // to hold the entry
char * products [100]; // to hold the products
  • To fill in the products array, read one product name from the user, check the length, and then allocate memory based on the length of the entered word. The following code is provided as an example:
cin >> Temp; // to get the product
int len = strlen(Temp) +1 ; // to determine the length of the product name
char* newProduct = new char[len]; // to allocate memory
strcpy(newProduct, Temp); // to copy the entry to a new product
products[0] = newProduct; // to save in the array
  • Use the previous structure to provide the same functionality that was provided in Week 4.
  • By the end of Week 5, your application should work as follows:
    • Ask the customer to enter his or her details (e.g., name and address).
    • Print a welcome message that includes the customers name.
    • Provide a list of available products with descriptions.
    • Ask the customer to select products and quantities.
    • Save the provided details in the new data structure.
    • Read from the arrays to print the order summary (e.g., the products, quantities, and total price for each product).
    • Calculate and print total price for the order.
    • Release the allocated memory.
    • Add comments to your code.
  • Summarize the changes that you implemented.
  • Discuss how using dynamic memory allocation changed your application structure.
Academic Honesty!
It is not our intention to break the school's academic policy. Projects posted are only used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly fill out the form. Please provide a valid email address and we'll get back to you in less than 24 hours. We will be sending an invoice through PayPal upon confirmation. We are a non profit organization however we need an amount to keep this organization running, and to be able to complete our research and development.