Question: 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

 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

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 f) 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 1 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 M1019 M101 14 C303 26 B202 31 F404 13 M1019 C303 38 B202 33 Figure 1: Sample data in the input file "input.txt" 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. ITEM NAME Double Mushroom Double BBQ Beef Grilled Chicken Fish'n Crisp TOTAL PROFIT (RM) 151.80 309.06 218.40 91.88 The total amount of profit = RM 527.46 Highest profit - RM 309.06 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 50 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. CODE ITEM NAME COST (RM) SALE (RM) QUANTITY PROFIT (RM) M101 Double Mushroom 11.50 14.95 12 41.40 B202 Double BBQ Beef 10.20 13.26 21 64.26 C303 Grilled Chicken 7.00 9.10 15 31.50 F404 Fish'n Crisp 6.25 8.12 9 16.88 F404 Fish'n Crisp 6.25 8.12 27 50.62 C303 Grilled Chicken 7.00 9.10 25 52.50 B202 Double BBQ Beef 10.20 13.26 16 48.96 M101 Double Mushroom 11.50 14.95 9 31.05 M101 Double Mushroom 11.50 14.95 14 48.30 C303 Grilled Chicken 7.00 9.10 26 54.60 B202 Double BBQ Beef 10.20 13.26 31 94.86 404 Fish'n Crisp 6.25 8.12 13 24.38 M101 Double Mushroom 11.50 14.95 9 31.05 C303 Grilled Chicken 7.00 9.10 38 79.80 B202 Double BBQ Beef 10.20 13.26 33 100.98 ITEM NAME TOTAL PROFIT (RM) Double Mushroom 151.80 Double BBQ Beef 309.06 Grilled Chicken 218.40 Fish'n Crisp 91.88 The total amount of profit - RM 527.46 Highest profit - RM 309.06 Figure 4: Complete output for the data from the input file "input.txt" 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

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!