Question
Problem 1 Write a program to repeatedly ask the user to enter information regarding inventory for a business (item part number, quantity, price) and then
Problem 1 Write a program to repeatedly ask the user to enter information regarding inventory for a business (item part number, quantity, price) and then saves the information to a file called inventory.txt. The program stops the loop when the user enters 0 for the part number. The program should function as follows (items underlined are to be entered by the user): This program stores a business inventory. Please enter item data (part number, quantity, price): 3, 1, 2.4 Please enter item data (part number, quantity, price): 1, 4, 3.0 Please enter item data (part number, quantity, price): 0 Thank you. Inventory stored in file inventory.txt. Note: ? Your program must write to the file in binary mode, using the fwrite function Save your program as save_inventory.c Challenge for problem 1 (10 extra credit points): Modify your program to check if the user enters an identical part number again. If this occurs, the program should print a message and ask for the input again. The program should function as follows (items underlined are to be entered by the user): This program stores a business inventory. Please enter item data (part number, quantity, price): 3, 1, 2.4 Please enter item data (part number, quantity, price): 1, 4, 3.0 Please enter item data (part number, quantity, price): 3, 4, 3.0 This item has been entered before. Please enter item data (part number, quantity, price): 2, 4, 1.3 Please enter item data (part number, quantity, price): 0 Thank you. Inventory stored in file inventory.txt. Save your challenge separately as save_inventory_c.c Problem 2 Write a program to read information from the inventory.txt file and display it to the screen, formatted as follows: Part#, Quantity, and Item Price in the table header should be separated by tabs. The part number field should take 5 spaces (values right justified), the quantity field should take 8 spaces (values right justified), and the price field should take 9 spaces with 2 numbers after the decimal (values right justified, with the $ sign in front of the price). The program should function as follows: Below are the items in your inventory. Part# Quantity Item Price 3 1 $ 2.40 1 4 $ 3.00 2 4 $ 1.30 Note: ? Your program must read from the file in binary mode, using the fread function Save your program as disp_inventory.c
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