14 Aug 5
- Part 5: Pointers
- 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 customer’s 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.
- The Documentation
- Update the project document with a new date and project name.
- Update previously completed sections based on instructor feedback.
- New content: Strings and Arrays
- Summarize the changes that you implemented.
Discuss how using dynamic memory allocation changed your application structure.
Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.
About Wridemy
We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.
How It Works
To make an Order you only need to click on “Place Order” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.
Are there Discounts?
All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.