Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I NEED IT FAST PLEASE!!! 2 Hours to complete Question 165 Marks Write a complete CH program. The program uses various types of structured data
I NEED IT FAST PLEASE!!! 2 Hours to complete
Question 165 Marks 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: Code M101 B202 C303 F404 Table 1 Name Double Mushroom Double BBQ Beef Grilled Chicken Fish'n Crisp Cost (RM) 11.5 10.0 12.5 15.0 (3 marks) Task 1: Declare a structure named Item, with the following members: a) Code b) Name c) Cost d) Sale price e) Number of items sold f) Profit d) The function should also calculate the sale price for cach item by adding 30% (markup percentage) to the cost of the item. Example, 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 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). Task 4: Write a function named displayOutput. (10.5 marks) a) This is a non-retuming 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' code, name, cost, sale price, number of itens sold, and profit. The formula for calculating itern profit is as follows: Tlem profil - Number of items sold (Sale price - Cost) d) Figure 2 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. ML01 12 3202 21 C303 15 74049 P404 27 C303 25 3202 16 M1019 MLOL 14 0303 26 3202 31 404 13 M1019 C303 38 3202 3.3 ------------------------------------------------- CODETTEN NAHR COST (RN SALE(ROM) ANTTTV PROPTT (RM) ------ 2101 Double Mushroom 11.50 14.95 12 41.40 R2n2 Touble RRO Beer 10.20 21 64.26 03C3 Grilled Chicken 7.00 9.10 15 31.50 2404 Fish'n Crap 8.12 16.99 74114 Fish'n Crisp 6.25 8.12 27 50.62 303 Grilled Chicken 7.00 25 52.50 B202 Doub. BRQ Beef 10.20 13.26 15 M101 Double Mushroom 11.50 14.95 3 31.15 Double Mushroom 11.50 11.95 10.30 0903 Crilled Chicken 7.00 9.10 25 R202 Double RRO Beer 10.20 13.76 31 2404 Fish'a Crisp ... 8.12 13 2101 Doub.c Mushroom 11.53 14.95 9 31.05 1313 Grilled Chicken 7.00 9.10 33 70.0 B2C2 Doulele De Beef 10.20 13.26 33 100.90 Figure 1: Sample data in the input file "input.txt" Figure 2: Expected output for Task 4 Task 3: Write a function named calculateSale Price. . (10.5 marks) a) This is a non-retuming 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. 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. 2 3 Task 7: List all function prototypes. (4 marks) 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 filc "input.txt" shown in Figure 1. (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. ITEM NAME Double Mushroom Double BBQ Beef Grilled Chicken Fish Criap TOTAL PROFIT (RM) 151.00 309.06 218.10 91.18 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 arc 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 STEM NAME COST (RM SALERN) OCAN CITY PROFITIRM) 12 22 15 41.40 50.26 31.50 50.62 52.50 M101 Double Mushroom B202 Double BBQ Beef C303 Grilled Chicken 7404 Tigh'n Crisp F404 Tish'n Crap C302 Crilled Chicken 5202 Double 352 Beef M201 Double Mushroom M101 Double Mushroon C303 Grilled Chicken 202 Double RO BART F404 ish'n Crisp M101 Double Mushroom C30.3 Grilled Chicken B202 Double BBQ Beef *** 11.50 13.20 7.00 6.25 6.95 7.00 13.20 11.50 11.50 7.00 10.20 6.25 11.50 7.00 13.20 14.95 13.26 9.10 8.12 8.12 9.10 13.26 14.95 14.95 9.10 13.26 9.12 14.95 9.10 13.26 25 16 9 114 25 13 9 28 33 31.05 18.30 54.60 94.85 24.38 31.05 79.80 100.98 ITEM NAME Double Mushroom Double BRO Ben Grilled Chicken pish'n Crisp TOTAL PRCFIT (RM) 151.80 209.06 218.40 The local amount of profil - RM 527.45 HigI 88L PI 0 || = 31 1.06 RM 309.06 -------------- Figure 4: Complete output for the data from the input file "input.txt" Question 165 Marks 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: Code M101 B202 C303 F404 Table 1 Name Double Mushroom Double BBQ Beef Grilled Chicken Fish'n Crisp Cost (RM) 11.5 10.0 12.5 15.0 (3 marks) Task 1: Declare a structure named Item, with the following members: a) Code b) Name c) Cost d) Sale price e) Number of items sold f) Profit d) The function should also calculate the sale price for cach item by adding 30% (markup percentage) to the cost of the item. Example, 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 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). Task 4: Write a function named displayOutput. (10.5 marks) a) This is a non-retuming 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' code, name, cost, sale price, number of itens sold, and profit. The formula for calculating itern profit is as follows: Tlem profil - Number of items sold (Sale price - Cost) d) Figure 2 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. ML01 12 3202 21 C303 15 74049 P404 27 C303 25 3202 16 M1019 MLOL 14 0303 26 3202 31 404 13 M1019 C303 38 3202 3.3 ------------------------------------------------- CODETTEN NAHR COST (RN SALE(ROM) ANTTTV PROPTT (RM) ------ 2101 Double Mushroom 11.50 14.95 12 41.40 R2n2 Touble RRO Beer 10.20 21 64.26 03C3 Grilled Chicken 7.00 9.10 15 31.50 2404 Fish'n Crap 8.12 16.99 74114 Fish'n Crisp 6.25 8.12 27 50.62 303 Grilled Chicken 7.00 25 52.50 B202 Doub. BRQ Beef 10.20 13.26 15 M101 Double Mushroom 11.50 14.95 3 31.15 Double Mushroom 11.50 11.95 10.30 0903 Crilled Chicken 7.00 9.10 25 R202 Double RRO Beer 10.20 13.76 31 2404 Fish'a Crisp ... 8.12 13 2101 Doub.c Mushroom 11.53 14.95 9 31.05 1313 Grilled Chicken 7.00 9.10 33 70.0 B2C2 Doulele De Beef 10.20 13.26 33 100.90 Figure 1: Sample data in the input file "input.txt" Figure 2: Expected output for Task 4 Task 3: Write a function named calculateSale Price. . (10.5 marks) a) This is a non-retuming 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. 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. 2 3 Task 7: List all function prototypes. (4 marks) 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 filc "input.txt" shown in Figure 1. (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. ITEM NAME Double Mushroom Double BBQ Beef Grilled Chicken Fish Criap TOTAL PROFIT (RM) 151.00 309.06 218.10 91.18 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 arc 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 STEM NAME COST (RM SALERN) OCAN CITY PROFITIRM) 12 22 15 41.40 50.26 31.50 50.62 52.50 M101 Double Mushroom B202 Double BBQ Beef C303 Grilled Chicken 7404 Tigh'n Crisp F404 Tish'n Crap C302 Crilled Chicken 5202 Double 352 Beef M201 Double Mushroom M101 Double Mushroon C303 Grilled Chicken 202 Double RO BART F404 ish'n Crisp M101 Double Mushroom C30.3 Grilled Chicken B202 Double BBQ Beef *** 11.50 13.20 7.00 6.25 6.95 7.00 13.20 11.50 11.50 7.00 10.20 6.25 11.50 7.00 13.20 14.95 13.26 9.10 8.12 8.12 9.10 13.26 14.95 14.95 9.10 13.26 9.12 14.95 9.10 13.26 25 16 9 114 25 13 9 28 33 31.05 18.30 54.60 94.85 24.38 31.05 79.80 100.98 ITEM NAME Double Mushroom Double BRO Ben Grilled Chicken pish'n Crisp TOTAL PRCFIT (RM) 151.80 209.06 218.40 The local amount of profil - RM 527.45 HigI 88L PI 0 || = 31 1.06 RM 309.06 -------------- Figure 4: Complete output for the data from the input file "input.txtStep 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