Microsoft Word - 20193_COP2000_Homework7_B.docx Homework Assignment 7 Pool COP2000 HOMEWORK ASSIGNMENT 7-B 1 Homework Assignment 7-B For this Assignment you will attach two files, the Analysis of the...

need helping writing this program


Microsoft Word - 20193_COP2000_Homework7_B.docx Homework Assignment 7 Pool COP2000 HOMEWORK ASSIGNMENT 7-B 1 Homework Assignment 7-B For this Assignment you will attach two files, the Analysis of the Problem (using Word or a text editor) and your program (.cpp file). Do not cut and paste your code into the message section of the assignment area or your program will not be graded and you will receive a zero for the assignment. If program does not compile you will automatically lose -10. PROBLEM: Tekka Toys Inventory Program. (20 pts) Write the Tekka Toys Inventory Program. The program will read a text file containing the following inventory data: inventoryData.txt (placed in a 2D array format): inventory2Data.txt [0] [1] [2] [0] [1] [0] unicorn yes yes [0] 10 30 [1] dragon yes yes [1] 5 10 [2] manticore yes no [2] 3 0 [3] mermaid yes yes [3] 0 10 [4] pegasus yes yes [4] 20 20 [5] sprite yes no [5] 10 0 [6] wizard yes no [6] 2 0 [7] elf yes yes [7] 0 5 [8] giant yes no [8] 6 0 [9] fairy yes yes [9] 15 0 Column [0] will represent the toy name, column [1] whether or not the toy is available as a plastic model (yes or no), and column [2] whether or not the toy is available as a stuffed animal. The related “parallel” array, inventory2Data.txt, holds all the quantities of the related toys, row [0] is related to row[0] of inventoryData.txt, i.e. it holds the quantity of unicorns available. For inventory2Data.txt, column [0] represents the number of plastic model toys available and column [1] represents the number of stuffed animals available. HOW THE PROGRAM WORKS: The program will first read in the file information from both files, sort the file by toy name (both files will need to be sorted accordingly), and write the files to new output files called newInventory.txt and newInventory2.txt, respectively. The program will then display a welcome message, the list of the “toys” available in alphabetical order, followed by the menu: Homework Assignment 7 Pool COP2000 HOMEWORK ASSIGNMENT 7-B 2 Read in the users input from the menu. Depending on the user’s input the program will execute accordingly: As long as the user did not enter 3 continue with the program and ask the user to enter the name of the toy they are looking for and read in the name of the toy. Check to see if that toy is available in the type they requested if it is then output the name, type and quantity available, if the toy is not available in the style they chose (plastic or stuffed), then output a message telling the user that the toy they chose is not available in that style and output the specific style that is not available. If the style of the toy was available but there were none in stock, output a message telling the user that no toys are in stock. If the user types in a toy name that is Not a valid toy name, then output an error message indicating that the toy name entered could not be found and allow the program to re-loop (see sample output). Your program will loop until the user chooses to exit the program and is done “checking” toys. Please see sample output for how this program will function. Your program MUST use input validation. Input Validation: The program must check to see if the input file exists, if the input file does not exit it must print an error message and exit the program correctly. You must validate your menu input. Input validation should be used to allow the program to function correctly as stated above in the program description. Note: Both Inventory Data text files are given to you in Blackboard within your Homework Folder. You MUST use the Inventory Data files given to you. Homework Assignment 7 Pool COP2000 HOMEWORK ASSIGNMENT 7-B 3 SAMPLE OUTPUT: Homework Assignment 7 Pool COP2000 HOMEWORK ASSIGNMENT 7-B 4 Homework Assignment 7 Pool COP2000 HOMEWORK ASSIGNMENT 7-B 5 Homework Assignment 7 Pool COP2000 HOMEWORK ASSIGNMENT 7-B 6 Homework Assignment 7 Pool COP2000 HOMEWORK ASSIGNMENT 7-B 7 PSEUDO-CODE for main function (one of many ways you can do your program): A. Declare Necessary Variables and 2D array to store data from input file. B. Call the readFile function and capture the returned value. C. Test if file was successfully read if so continue with program else exit with error message. D. Call the sortInput function E. Do while…. a. call showMenu function b. readin user input c. validate user input and loop if invalid input entered d. use switch statement or if statements to check user input i. if user input equals 1 or 2 then call the ckInventory function ii. if user input equals 3 then allow program to exit CONSTRAINTS: • No global variables allowed. (Automatic -10) Note: This means that all your arrays must be declared inside of main. • You must use: int main() • You must use input validation. • The program must use local variables. (2 pts) • You must use functions and they must be called by main. (2 pts) • Output must be formatted properly and correct. (2 pts) • Include a comment at the beginning of the program stating the purpose of the program, your name, the date, and your class (1pt is for code organization and use of whitespace). (3 pts) • The program must read in data from an input file. (2 pts) • The program must output the results both to the console and to an output file. (1 pts) • This program MUST use the following functions: (8 pts) NAME YOUR FUNCTIONS AS SHOWN BELOW (- 7 if not named correctly): bool readFile(string inventory[10][3], int inventory2[10][2]) - (2 pts) is passed the array which will store all the toy string data and all the toy numerical data which will be read from two different files. This function will open each input file and read in the data from each input file and put the appropriate data in the related array. You Must Validate that the input file exists. If the file was not read in the function should return false and error message should be output in main that the program will exit due to an error in reading the file. void showMenu (string inventory[10][3]) - (1 pts) is passed the inventory data for the toy string information which contains the names of the toys. The showMenu() function will show the welcome screen, print out the available toys, and the menu options. This function returns nothing. Include the following welcome message and menu in your function (see sample output for usage): Homework Assignment 7 Pool COP2000 HOMEWORK ASSIGNMENT 7-B 8 Welcome Screen: ***************************** * Welcome to Tekka Toys * * Please follow the menu * * Below to check our * * Inventory… * ***************************** Menu: Please check our inventory if you are interested… 1. Stuffed Toy 2. Plastic Toy 3. Exit > void sortInput (string inventory[10][3], int inventory2[10][2]) - (2 pts) is passed the array which stores all string inventory data and the array that stores all the numeric inventory data. The sortInput() function uses a sorting algorithm to sort the inventory data by toy name. Since the inventory2 array is related to the inventory array this array must be simultaneously sorted with the inventory array to keep the ordering correct. Output the sorted files to newInventory.txt and newInventory2.txt. This function returns nothing. void ckInventory (string inventory[10][3], int inventory2[10][2], int toyType); - (3 pts) is passed the array which stores the string inventory data and the array that stores all the numeric inventory data. In addition, it is sent the toyType which is the menu option chosen from main. The ckInventory() function – (check inventory) – is used to check the toy inventory. You will first ask the user what toy they would like to check in inventory then display the toy name, the style of the toy and the quantity in stock if that toy is available in the style they chose. If the toy is not available in the style they chose, you must output a message indicating the toy style they chose is not available. If the toy style is available but out of stock, you must output a message indicating that the toy is out of stock. (See sample output for detailed output). You must always output the toy name and style. HINTS: You will need the library to read and write data from a file. This library also allows you to declare your file stream object, i.e. ifstream inputFile; //an ifstream object – input file stream object inputFile.open(“Customers.txt”); // the open member function opens the text file and links it with // inputFile to read data from the Customers.txt file //To close a file inputFile.close( ); Homework Assignment 7 Pool COP2000 HOMEWORK ASSIGNMENT 7-B 9 Use the index in the back of your book to look up “Files”, opening and closing,
Dec 01, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here