C Vending Machine Program Design
C Vending Machine Program Design
vending machine
Abstract:
This provided code implements a vending machine program in C. It utilizes a Product
structure to store information about products, including name, price, quantity, and
expiration status. The program displays a menu of available products, allows the user to
select and purchase items, calculates change, and updates product quantities. The code
exemplifies the use of structures, loops, and standard input/output. Opportunities for
Enhancement, such as input validation and code modularization, are highlighted.
General objective
Design a system of algorithms and pseudocode that simulates the functioning of a
vending machine capable of selling products and handling transactions efficiently
efficient and precise. The project seeks to create a program that allows the user
select products, enter the necessary money for the purchase, check the balance
available, deliver the selected product and, if necessary, return the change
corresponding.
By achieving this objective, the project will demonstrate the ability to create algorithms and
pseudocode to simulate a typical interaction between a client and a machine
vending machine, providing a close to real experience. Additionally, it is expected that the
the program is easily scalable and adaptable for future improvements or additions
characteristics.
Specific objectives
[Link] the system logic: Create an algorithm that allows the user to interact.
with the vending machine, select products, insert the money, and receive the change
corresponding.
3-. Validate the customer's balance: Create an algorithm that checks if the customer's balance is
enough to purchase the selected product and handles it properly
transactions with insufficient balances.
[Link] change correctly: Design an algorithm that calculates and delivers the
exchange for the customer after a purchase, if necessary.
5-. Show relevant information: Implement an algorithm that displays to the client
useful information, such as the product price, available balance, and quantity of
remaining products.
[Link] usability: Ensure that the program is intuitive and easy to use,
clear messages and well-defined options to facilitate user interaction.
7-. Validate and correct errors: Implement mechanisms to detect and handle errors,
such as entering invalid data or selecting unavailable options.
[Link] thorough testing: Test the program with different scenarios and data
for testing to ensure that it works correctly and meets the requirements
established.
[Link] the code: Create clear and concise documentation that explains the
functioning of the algorithm and pseudocode, facilitating its understanding and possible
future expansion or modification.
Justification
The realization of the integrative project is justified for various reasons:
1-. Practical application of algorithms and pseudocode: This project allows for the application
the knowledge of algorithms and pseudocode in a realistic context. The machine
a vending machine is a common scenario in everyday life, and designing an algorithm for
simulating its operation provides a valuable hands-on experience.
5-. Scalability and adaptability capacity: When developing an algorithm for the
vending machine, it is important to consider scalability to add new ones
products or functionalities in the future. This experience enhances the skills to
design modular and adaptable systems.
6-. Testing and debugging of the algorithm: The completion of the project involves performing
exhaustive testing of the algorithm to ensure its proper functioning and correction
possible errors. This helps strengthen debugging skills and improves quality
of the code.
7-. Awareness of limitations and efficiency: When designing the algorithm, one must take into account
It accounts for the efficiency and optimization of the code to achieve a user experience.
fluid. This practice increases awareness of the importance of efficiency in the
algorithm design.
State of the art
Below are some projects/jobs that are related to this work.
-
Start
Wish
acquire a
product
Choose a
product of 1-6
Do you want
choose more
of one
cantdad?
Pay with (only coins
coins/banknote from 1,2,5,10)
Process
finalized!
End
Pseudocode (C Language)
#include <stdio.h>
int main() {
int initial_money = 500;
int total_money = initial_money;
Product array
struct Product products[6] = {
{"Frituras", 10, 10, 0},
{"Refresco", 15, 10, 0},
{"Galletas", 13, 0, 1},
{"Chocolate en barra", 5, 0, 1},
{"Jugo", 12, 10, 0},
{"Cacahuates", 8, 10, 0}
};
while (selected != 0) {
if (selected < 1 || selected > numProducts ||
isExpired(products[selected - 1]) {
Invalid option or expired product. Please try again.
} else {
struct Producto *selected_product = &products[selected - 1];
return 0;
}
Development
Initial phase
Here, the basic concepts must be understood in order to program (in this case
In C language), the input is first made #include <studio.h> for input and
make the code work.
Subsequently, the data to be used for the coding and execution must be declared.
vending machine, to subsequently use this data to perform the functions
desired.
Function to display the menu of available products: Here we write with the
printf function for
While loop: The program enters a while loop that repeats until the user
Enter 0 to exit the machine.
Product selection: The user can select a product by entering the number.
corresponding in the menu. It is verified if the option is valid and if the product is not
expired. If the option is invalid or the product is expired, a message is displayed
of error and the menu is displayed again.
Purchase and change calculation: If the option is valid and the product is not expired, the
the program asks the user to enter the money to buy the product. It checks if the
The money submitted is sufficient for the purchase and change is calculated if necessary.
Then the total money record and the inventory of the purchased product are updated.
End of the cycle: After each purchase, the product menu is displayed again.
so that the user can make another purchase or exit the machine.
When developing the vending machine algorithm, it required great care when designing
the diagram, and even more in terms of the code, likewise, it was successfully possible to
present this project in order to develop what was learned so that in the institution is
represented as a unit that complies with the education and teaching in the fundamentals of
the career that is being studied.
Conclusiones
For the formalization of a vending machine, a system has been successfully developed.
efficient and safe to operate and manage the vending machine effectively. Have
analizado los requisitos y regulaciones aplicables y se han implementado las medidas necesarias
to comply with the current regulations.
Through the formalization of the vending machine, the experience of has been improved.
user by providing a friendly and easy-to-use interface. In addition, a system has been implemented
real-time inventory control, which has allowed for the optimization of product replenishment and
ensure their availability.
Security has also been a priority in the project. Mechanisms have been implemented for
authentication and encryption to protect user information, as well as detection systems
of frauds and manipulations.
In summary, the project has been successful in the formalization of a vending machine.
improving its performance, security, and user experience. It is expected that this
implementation serves as a basis for future projects.
For the formalization of a vending machine, it has been possible to develop an efficient and safe
system to operate and manage the vending machine effectively. The applicable requirements and
Regulations have been analyzed and the necessary measures have been implemented to comply.
with current standards.
Through the formalization of the vending machine, it has been possible to improve the user
experience by providing a friendly and easy-to-use interface. In additon, a real-tme inventory
A control system has been implemented, which has made it possible to optimize the replacement of
products and guarantee their availability.
Safety has also been a priority in the project. Authentication and encryption mechanisms have
been implemented to protect user information, as well as fraud and manipulation detection
systems.
In summary, the project has been successful in the formalization of a vending machine, improving
its operation, security and user experience. It is expected that this implementation will serve as the
basis for future projects.
Bibliographic sources
-Luna, J. I.V., Acosta, M. A. L., Guzmán, G. S., Vargas, V. N.T., Rangel,F.J. S., &
Aceves, J.F.C. (2018). Inventory of vending machines using a
LPWAN. National Technology of Mexico, (article made using PHP).
[Link]
-Priscila Ximena Reinoso Solís, María del Cisne Zúñiga Jácome. (2011).
Development of a business plan for the marketing of food through
of vending machines within the University of Azuay. Cuenca, Ecuador.
University of Azuay Official
[Link]