Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a complete CH program. The program uses various types of structured data developed to calculate the profit of each item, the total amount of

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Write a complete CH 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 (c). 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 "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. 2 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 (c). 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 "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. 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 216.40 91.00 The total amount of profit = RM 527.46 Highest profit = RM 309.06 Figure 3: Expected output for Task 5 Task 6: Write a nain 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 fomatting. 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 B202 Double BBQ Beef C303 Grilled Chicken F404 Fish'n Crisp F404 Fish'n Crisp C303 Grilled Chicken B202 Double BBQ Beef M101 Double Mushroom M101 Double Mushroom C303 Grilled Chicken B202 Double BBQ Beef F404 Fish'n Crisp M201 Double Mushroom C303 Grilled Chicken B202 Double BBQ Beef 11.50 10.20 7.00 6.25 6.25 7.00 10.20 11.50 11.50 41.40 64.26 31.50 16.88 50.62 52.50 14.95 13.26 9.10 8.12 8.12 9.10 13.26 14.95 14.95 9.10 13.26 8.12 14.95 9.10 13.26 31.05 48.30 54.60 10.20 6.25 11.50 7.00 10.20 31 13 9 24.36 31.05 79.80 100.98 33 ITEM NAME Double Mushroom Double BBQ Beef Grilled Chicken Fish'n Crisp TOTAL PROFIT (RM) 151.80 309.06 218.40 91.60 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. Write a complete CH 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 (c). 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 "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. 2 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 (c). 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 "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. 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 216.40 91.00 The total amount of profit = RM 527.46 Highest profit = RM 309.06 Figure 3: Expected output for Task 5 Task 6: Write a nain 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 fomatting. 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 B202 Double BBQ Beef C303 Grilled Chicken F404 Fish'n Crisp F404 Fish'n Crisp C303 Grilled Chicken B202 Double BBQ Beef M101 Double Mushroom M101 Double Mushroom C303 Grilled Chicken B202 Double BBQ Beef F404 Fish'n Crisp M201 Double Mushroom C303 Grilled Chicken B202 Double BBQ Beef 11.50 10.20 7.00 6.25 6.25 7.00 10.20 11.50 11.50 41.40 64.26 31.50 16.88 50.62 52.50 14.95 13.26 9.10 8.12 8.12 9.10 13.26 14.95 14.95 9.10 13.26 8.12 14.95 9.10 13.26 31.05 48.30 54.60 10.20 6.25 11.50 7.00 10.20 31 13 9 24.36 31.05 79.80 100.98 33 ITEM NAME Double Mushroom Double BBQ Beef Grilled Chicken Fish'n Crisp TOTAL PROFIT (RM) 151.80 309.06 218.40 91.60 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

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 Systems For Advanced Applications 15th International Conference Dasfaa 2010 Tsukuba Japan April 2010 Proceedings Part 1 Lncs 5981

Authors: Hiroyuki Kitagawa ,Yoshiharu Ishikawa ,Wenjie Li ,Chiemi Watanabe

2010th Edition

3642120253, 978-3642120251

More Books

Students also viewed these Databases questions

Question

Describe the types of multiblade dampers.

Answered: 1 week ago

Question

(1) R (U + 211D),7 which is the set of all real numbers;

Answered: 1 week ago