Question: Question 165 Marks Write a complete C++ program. The program uses various types of structured data developed to calculate the profit of each item, the

 Question 165 Marks Write a complete C++ program. The program uses
various types of structured data developed to calculate the profit of each
item, the total amount of profit, and the highest profit. The program
should perform the following tasks: Task 1: Declare a structure named Item
with the following members: (3 marks) a) Code b) Name c) Cost

Question 165 Marks Write a complete C++ program. The program uses various types of structured data developed to calculate the profit of each item, the total amount of profit, and the highest profit. The program should perform the following tasks: Task 1: Declare a structure named Item with the following members: (3 marks) 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 itemis. 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 (c). M101 12 B202 21 C303 15 74049 F404 27 C303 25 B202 16 M1019 M101 14 C303 26 3202 31 F404 13 M2019 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 Code M101 B202 C303 F404 Table 1 Name Double Mushroom Double BBQ Beef Grilled Chicken Fish'n Crisp Cost (RM) 11.5 to 10.2 125 1 1 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 NAME SALE (RM) QUANTITY PROFIT (RM) 32 21 41.40 64.26 31.50 13.26 9.10 8.12 8.12 9.10 27 50.62 $2.50 COSTI) 11.30 10.20 7.00 6.25 6.25 7.00 10.20 11.50 11.50 7.00 10.20 6.25 11.50 7.00 10.20 MIOL Double Mushroom B202 Double BBQ Beet C303 Grilled Chicken F404 Plohn Crisp 7404 Fish'n Crisp 0303 Grilled chicken B202 Double BBQ Bot MOI Double Mushroom MIOL Double Mushroom 0303 Grilled Chicken 202 Double BBQ Bet 8404 Plan Crisp MOI Double Mushroom 0303 Grilled Chicken 3202 Double BBQ Beet 16 16.95 31.05 25 31 54.60 9.30 13.26 8.12 14.95 24.38 31.05 79.80 100.98 33 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. Fed Chloe 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. 3 d) The function should also calculate and display the total amount of profit for all items and the highest profit e) Figure 3 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. IT TOTAL NOTE Doble Hushree Double et 300.00 Crilled che Pusha CD The total to profit - 1027.46 | Hng thng trt H + HI V Figure 3: Expected output for Task 5 Task 6: Write a main function to perform the following tasks (5 marks) a) Declare one-dimensional array variable with S0 elements for a structure type Item. b) The function may need to call the functions that are defined in the previous task to produce the output as shown in Figure 4. Note: Please use proper output formatting c) Figure 4 shows the complete output that will be displayed on the screen based on the data in the input file "input.txt" shown in Figure 1. COOL TO ME COST LALEO) GUANTITY PROPIT 10 De Mon 1202 Double Beer 10:20 SA Grand schen 9.10 DEL Cap 9.22 1.12 6.25 9.10 Beer 13.20 MIDI I MO 14.95 MOL De 12.50 7.00 C203 Chicken N H.60 Double Beer 96.16 7404 Doble Mishon c303 Grilled teken 5.10 79.00 202 Dobele 180 ITEMA TOTAL PROPITER Double Moon Double Beat Grilled Chicken Tim's Cup 31.50 10.20 9.10 13.26 16.30 12.10 309.06 216.40 91.88 The total amount of protit -597.46 HEXAL CODE ITEM MANGE COST SALE TRE) QUANTITY M101 Double Minhen 11.50 14.95 41.40 8202 Double BBQ Beer 10.20 13.26 C103 drilled Chicken 7.00 9.10 31.50 1404 Ton Crisp 16.18 7404 Plain Crisp 6.25 8.12 22 50.63 c303 Grilled Chicken 7.00 52.50 1202 Double B Beef 10.20 23.26 48.96 MIOI Double Maroon 11.50 16.95 31.05 201 Double Hushoc 48.30 303 Grilled Chicken 7.00 54.60 1202 Double Beer 10.20 23.26 31 90.00 1404 Yan Crisp 5.25 24.30 101 Double Mushroom 11.50 14.95 31.05 C303 Grilled Chicken 7.00 19.10 202 Double Beef 200.90 ITINE TOTAL PROFITEMI Double Mushroom 151.00 Double Beer 305.00 GESled Chicken 218.40 Fish Crisp The total amount of prorit -9.46 Wighest profit - RM 30.06 Figure 4: Complete output for the data from the input file "input.txt" (4 marks) Task 7: List all function prototypes 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!