Hello, if you have any need, please feel free to consult us, this is my wechat: wx91due
C Programming Language
Contribution to module (weighting: 50 %)
1st Semester 2024-2025
Assignment name:Mini-app for grocery store management
Out: THU. 5th Dec. 2024 Due: THU. 26nd Dec. 2024
- Learning to draw flow charts to describe the problem and the corresponding solution.
- Practicing coding and building a C program to solve the given problem.
- Learning to write a technical report to help others understand your program.
You are given a struct type to present products (see Table 1 and Table 2 as listed below). Finish the assignment with given information.
- Draw flow charts for all functions you want to write in your program (see Figure 1 for example);
- Explain how the structures and functions are used in your program;
- Wrte the source code in C language, and compile them to build the program;
- Run the program on your computer and screenshot the execution results;
- Write a technical report to include all the aforementioned contents
Figure 1 A flow chart showing a function that iteratively reads a char from the user and outputs the char.
Problem description:
You are required to use an array (or other data structure) of struct product to manage the records in Table 1 (which is originally stored in a file named “product.txt”).
Table 1 Product records (stored in a file named “product.txt”).
prono |
fullname |
price |
101 |
mango |
3.5 |
102 |
orange |
2.4 |
103 |
banana |
2.8 |
104 |
watermelon |
3.7 |
105 |
pineapple |
4.1 |
106 |
blueberry |
5.0 |
107 |
cherry |
5.5 |
108 |
cucumber |
1.9 |
109 |
cabbage |
2.0 |
110 |
broccoli |
3.1 |
111 |
celery |
1.9 |
112 |
pea |
4.5 |
113 |
<product name> |
<product price> |
HINT: function pointers.
3. Sales records can be retrieved from Table 2. First, write a function to sort sales records by month. Secondly, write another function to display sales records on the screen with the product information like the following example. Likewise, as a requirement, the sort function must be passed to the display function as a parameter.
Figure 2 A sample output on the screen.
Table 2 Sales records (stored in a file named “salelist.txt”).
prono |
month |
sales volume |
discount |
101 |
Sep. |
41 |
10% off |
101 |
Oct. |
48 |
none |
102 |
Nov. |
50 |
10% off |
103 |
Aug. |
43 |
10% off |
103
|
Sep.
|
56
|
none |
104
|
Nov.
|
64
|
20% off |
105
|
Sep.
|
71
|
none
|
105
|
Nov.
|
63
|
10% off |
105
|
Dec.
|
33
|
10% off |
106
|
Sep.
|
88
|
10% off
|
106
|
Aug.
|
78
|
none |
106
|
Physics
|
91
|
none |
106
|
Nov.
|
65
|
20% off |
106
|
Dec.
|
82
|
10% off |
107
|
Nov.
|
86
|
10% off |
107
|
Dec.
|
48
|
none |
107
|
Dec.
|
41
|
none |
108
|
Sep.
|
38
|
none |
108
|
Dec.
|
56
|
20% off
|
108 |
Nov.
|
58
|
none |
108
|
Nov.
|
98
|
10% off |
109 |
Aug.
|
63
|
10% off |
110
|
Sep.
|
73
|
10% off |
110 |
Nov.
|
43
|
none |
110 |
Dec.
|
80
|
none |
110
|
Dec.
|
65
|
20% off |
111 |
Sep.
|
95
|
20% off |
111 |
Nov.
|
89
|
none |
111 |
Oct.
|
96
|
none |
112
|
Sep.
|
36
|
none |
112
|
Nov.
|
73
|
10% off |
112
|
Oct.
|
21
|
none |
4. Calculate the total sale volume and average sale volume of each product respectively, and output the them on screen.
5. Output all sales data of September with product information, write the result to a new txt file and name the file with your Brunel id.
6. Calculate the total sale of each product, and output the top three on the screen. To achieve this, you need to know that price of each product varies according to discount of each month. For example: the price of mango in September has a discount of 10% off. In other words, the price of mango in September is 3.15. The total sale of mango in September equals the total sale volume of mango in September multiple the price of mango in September. Finally, we can get the total sale of mango by adding up the sales of mango in September, October,November and December.