Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C Language Program. PLEASE USE DYNAMIC MEMORY AND FOLLOW DIRECTIONS GIVEN. USE FUNCTIONS GIVEN ALSO. Thank you. NO FFLUSH. Problem 5 (40 points)-Write a program
C Language Program. PLEASE USE DYNAMIC MEMORY AND FOLLOW DIRECTIONS GIVEN. USE FUNCTIONS GIVEN ALSO. Thank you. NO FFLUSH.
Problem 5 (40 points)-Write a program Submit orders.c (Note: you wil be dynamically allocating memory for this problem. The second argument on the command line will let you know how much memory you will be allocating. O points if you do not dynamically allocate) Chef Bartolomeo owns a very busy Italian restaurant. He has recently started accepting orders online and every morning he puts all orders into a text file. He has asked you to create a program with the following functionality: 1) Upon opening the program, the program should greet him with the phrase "Buongiorno Chef Bartolomeo! The program should then read each order given in the text file into a struct. The information given in the file is in the following format: Allegra Rossi,m,5,11.99,2 where Allegra Rossi is name, m stands for payment in cash (and c would mean payment with a credit card), 5 is the total number of items ordered, 11.99 is the total amount spent by the customer for the order, and 2 means the order has not yet been fulfilled (1 would mean the order has been fulfilled). 2) The program should allow him to print out the names on orders that have been fulfilled or orders that have not been fulfilled. 3) The program should be able to pick the next order to fulfill. The next order is determined by the order that has the highest price. The program should then ask if he wants to fulfill this order or not. If all orders have been fulfilled, then the program should say so and return to the menu. 4) If Chef Bartolomeo decides to exit the program, all information should be saved exactly as it is into the same file opened. This way, when he decides to open the program again, he can pick up where he left off. Step 1: Define a struct to hold in the information for each order Step 2: Define the following functions: This function should read the file (given on the command line) into the appropriate number of order structs The size is the number of orders (given on the command line-see sample run) void input orders(order o, int size, char filename) /This function should print out all orders from the order structs depending on the status parameter. The size parameter indicates the number of structs in the array." void print out(int status, order o, int size) /This function should take the order structs and return the index of the next order to be fulfilled Ifall orders are fulfilled, the function should return -1."/ int pick next(order o, int size) This function should output all the current information stored in the order structs into the same file that was read in. void output file(char filename, order o, int size) Step 3: Combine the struct and functions you defined above to make a working program. Sample Run: computers gcc-o orders orders.c computers /orders 3 customer.txt "Buongiorno Chef Bartolomeo! What to do? 1. print out orders 2. pick next order to fulfill 3. exit Do you want to see all orders to fill or orders already completed? Type fill or completed fill Need to fill: Allegra Rossi Pietro Romano What to do? 1. print out orders 2. pick next order to fulfill 3. exit Do you want to see all orders to fill or orders already completed? Type fill or completed Already filled: Francesco Bianchi What to do? 1. print out orders 2. pick next order to fulfill 3. exit Next orderto fill: Pietro Romano Go ahead and fulfill this order? y or n Not fulfilled. What to do? 1. print out orders 2. pick next order to fulfill 3. exit Next order to fill: Pietro Romano Go ahead and fulfill this order? y or n Fulfilled! What to do? 1. print out orders 2. pick next order to fulfill 3. exit Do you want to see all orders to fill or orders already completed? Type fill or completed fill Need to fill Allegra Rossi What to do? 1. print out orders 2 pick next order to fulfill 3. exit Not a valid menu choice. What to do? 1. print out orders 2. pick next order to fulfill 3, exit Saving information...Ciao 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