Question
Task 5: Write a function named displayAnalysis . (17 marks) This is a non-returning function. It takes an array of Item of type struct and
Task 5: Write a function named displayAnalysis. (17 marks)
- This is a non-returning function.
- It takes an array of Item of type struct and the number of items calculated in Task 2 as input parameters.
- The function should display items names and total profit for each item.
- The function should also calculate and display the total amount of profit for all items and the highest profit.
- Figure 3 shows an example of the output that will be displayed on the screen based on the data in the input file "data.txt" shown in Figure 1.
--------------------------------------------------------------------
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 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.
- 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.
- Figure 4 shows the complete output that will be displayed on the screen based on the data in the input file "data.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
F404 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 in the input file "data.txt"
Task 7: List all function prototypes.
| (4 marks) |
Task 8: You must ensure your program fulfill the following criteria:
| (5 marks) |
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