Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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)

  1. This is a non-returning function.
  2. It takes an array of Item of type struct and the number of items calculated in Task 2 as input parameters.
  3. The function should display items names and total profit for each item.
  4. The function should also calculate and display the total amount of profit for all items and the highest profit.
  5. 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.

  1. 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.
  2. 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:

  1. The program is able to run.
  2. All required header files are included.

(5 marks)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Understanding Databases Concepts And Practice

Authors: Suzanne W Dietrich

1st Edition

1119827949, 9781119827948

More Books

Students also viewed these Databases questions