Question: (3 marks) Task 1: Declare a structure named Item, with the following members: a) Code b) Name c) Cost d) Sale price e) Number of


(3 marks) Task 1: Declare a structure named Item, with the following members: a) Code b) Name c) Cost d) Sale price e) Number of items sold 1) Profit Task 2: Write a function named readInput. (10 marks) a) It receives an array of Item of type struct. b) The function should read data from the given input text file named input.txt. The file contains items' codes and the number of items sold. Figure I shows an example of data that can be used to test the program. c) Assuming you do not know, the number of items. Calculate the number of items sold based on the number of item records found in the input file. d) The function should return the number of items calculated in (e). M101 12 B202 21 C303 15 F404 9 F404 27 C303 25 B202 16 M101 9 M101 14 C303 26 B202 31 F404 13 M1019 C303 38 B202 33 Figure 1: Sample data in the input file "input.txt" Task 3: Write a function named calculateSalePrice. (10.5 marks) a) This is a non-returning function, b) It takes an array of Item of type struct and the number of items calculated in Task 2 as input parameters. c) The function should determine the items' names and cost based on the information given in Table 1. 2 Code M101 B202 C303 F404 Table 1 Name Double Mushroom Double BBQ Beef Grilled Chicken Fish'n Crisp Cost (RM) 11.5 10.0 12.5 15.0 d) The function should also calculate the sale price for each item by adding 30% (markup percentage) to the cost of the item. Example, if an item costs RM50 to produce, and you want to apply a mark-up of 25%, you need to multiply 50 by 1.25. The sale price would be RM62.50. Task 4: Write a function named displayOutput. (10.5 marks) a) This is a non-returning function. b) It takes an array of Item of type struct and the number of items calculated in Task 2 as input parameters. c) The function should display items" code, name, cost, sale price, number of items sold, and profit. The formula for calculating item profit is as follows: Item profit = Number of items sold (Sale price - Cost) d) Figure 2 shows an example of the output that will be displayed on the screen based on the data in the input file "input.txt" shown in Figure 1. CODE ITEM MANE COSTER SALE(R) QUANTITY 14.95 12 9.10 8.12 PROFIT (R41 41.40 64.26 31.50 15.88 50.62 $2.50 9 11.50 10.20 7.00 5.25 6.25 2.00 10.20 11.50 11.50 7.00 10.20 M10: Double Mushroom B202 Double SRO 5 0303 Grilled Chicken F404 Fish'n Crisp 7404 Push'n Crisp 0303 Elled Chicken B202 Double BBQ Boot 101 Double Mushroom 103 Double Mushroom C303 Grilled Chicken 3202 Double Beat 404 Fish'n Crisp M101 Double Mushroom C303 Grilled Chicken B202 Double 380 Beet 25 9.10 13.26 24.95 14.95 26 31 31.05 48.30 54.60 94.86 24.38 31.05 29.80 100.9 13.26 8.12 14.95 9.10 13.26 11.50 7.00 10.20 9 Figure 2: Expected output for Task 4 Task 5: Write a function named displayAnalysis. (17 marks) a) This is a non-returning function. b) It takes an array of Item of type struct and the number of items calculated in Task 2 as input parameters. c) The function should display items' names and total profit for each item. Task 7: List all function prototypes. (4 marks) (5 marks) Task 8: You must ensure your program fulfill the following criteria: a) The program is able to run. b) All required header files are included
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
