Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task 1: Declare a structure named Item , with the following members: (3 marks) a) Code Name Cost Sale price Number of items sold Profit

Task 1: Declare a structure named Item, with the following members: (3 marks) a) Code

  1. Name
  2. Cost
  3. Sale price
  4. Number of items sold
  5. Profit

Task 2: Write a function named readInput. (10.5 marks)

  1. It receives an array of Item of type struct.
  2. The function should read the data from the given input file named data.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.

M101, 12 B202, 21 C303, 15 F404, 9 F404, 27 C303, 25

B202, 16 M101, 9

M101, 14 C303, 26 B202, 31

F404, 13 M101, 9

C303, 38 B202, 33

Figure 1: Sample data in the input file "data.txt"

  1. 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.
  2. The function should return the number of items calculated in (c).

Task 3: Write a function named determineNameCost. (10.5 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 determine the items names and cost based on the information given in Table 1.

Table 1

Code

Name

Cost (RM)

M101

Double Mushroom

11.5

B202

Double BBQ Beef

10.0

C303

Grilled Chicken

12.5

F404

Fish'n Crisp

15.0

  1. The function should also calculate the sale price for each item by adding 30% (markup percentage) to the cost of the item. 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 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 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)

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

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

--------------------------------------------------------------------

Figure 2: Expected output for Task 4

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

Database Development For Dummies

Authors: Allen G. Taylor

1st Edition

978-0764507526

More Books

Students also viewed these Databases questions

Question

What is Constitution, Political System and Public Policy? In India

Answered: 1 week ago

Question

What is Environment and Ecology? Explain with examples

Answered: 1 week ago

Question

7. It is advisable to do favors for people whenever possible.

Answered: 1 week ago

Question

9. Power and politics can be destructive forces in organizations.

Answered: 1 week ago