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:
- Review your algorithm.
- Declare the structure definition called Shoes that can store the shoe data listed above.
- Create a Shoes structure pointer variable for storing one database record (that is one line from the file).
- Create a vector of type Shoes* that will hold the shoe inventory from the file.
- Write your code that prompts the user for the input filename, opens the file, and checks for failure.
- Create a new Shoes structure from dynamic memory.
- Read a line from the file and copy the shoe data into that new Shoes variable.
- Add that new Shoes to the vector.
- Repeat lines seven and eight until all the data from the file has been read.
- Close the file.
- Sort the shoe inventory by shoe size (low-to-high).
- Inform the user how many lines were read.
- Display the shoe inventory data from the vector on the screen.
- Be sure to delete the dynamically allocated memory after the shoe records are displayed.
- Make sure to thoroughly test your program.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started