Question: Super Shoe Store Program Design an algorithm that will load the shoe inventory from a file into a dynamically allocated database . The database will

Super Shoe Store Program

Design an algorithm that will load the shoe inventory from a file into a dynamically allocated database. The database will use a structure to store the shoe data. The pointers to each structure will be contained in a vector.

The structure definition should be able to store the following information:

Shoe Data

Data Values

Shoe Type

Dress, Casual, Sandals, Sneakers, Boots

Size

6 through 12 including half sizes

Width

A, B, D

Color

White, Tan, Blue, Red, Black

Quantity

0 or more

When the program begins display a welcome message. Prompt the user for the input filename. If the file does not open, display an error message.

The shoe inventory file is tab delimited with four fields: shoe type, size, width, color, and quantity. For each line in the input file, dynamically allocate memory for a new structure and add the pointer to that structure to your pointer vector. Once the entire file is loaded, close the input file.

The input file will be in the following format:

Dress 6 B Black 5

Boots 9 A Red 10

Sandals 6.5 B Blue 7

Sneakers 8.5 D White 20

The program data is in a text file called Shoes.txt. You can use this file to test your program. However, it should also work with other input files.

You should create and use functions for each of the following tasks:

  • Open and read the file into the vector.
  • Sort the vector data by shoe size (low-to-high).
  • Display the output to the screen.
  • Release the dynamically allocated memory.

Feel free to add any additional functions you think will improve your program.

Format your output like the example below:

Super Shoe Store Inventory Report

Shoe Type Size Width Color Quantity

--------------------------------------------------------

Dress 6 B Black 5

Sandals 6.5 B Blue 7

Sneaker 8.5 D White 20

Boots 9 A Red 10

Programming Suggestions

Once you have completed this design document and are ready to begin coding, you may find the following tips helpful:

Perform the follow steps in this order:

  1. Review your algorithm.
  2. Declare the structure definition called Shoes that can store the shoe data listed above.
  3. Create a Shoes structure pointer variable for storing one database record (that is one line from the file).
  4. Create a vector of type Shoes* that will hold the shoe inventory from the file.
  5. Write your code that prompts the user for the input filename, opens the file, and checks for failure.
  6. Create a new Shoes structure from dynamic memory.
  7. Read a line from the file and copy the shoe data into that new Shoes variable.
  8. Add that new Shoes to the vector.
  9. Repeat lines seven and eight until all the data from the file has been read.
  10. Close the file.
  11. Sort the shoe inventory by shoe size (low-to-high).
  12. Inform the user how many lines were read.
  13. Display the shoe inventory data from the vector on the screen.
  14. Be sure to delete the dynamically allocated memory after the shoe records are displayed.
  15. Make sure to thoroughly test your program.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!