C – Vending Machine
A fully functional console‑based drink dispenser written in C. Manages coin payments, change, admin authentication, and persistent sales statistics.
📦 Ressources
Windows executable and complete C source code available. Clone or download from GitHub.
Clone the repository or download the executable to test the vending machine.
🎥 Video Demonstration
Watch the vending machine in action – from coin insertion to admin panel.
The video shows the complete user journey: selecting a drink, inserting coins, receiving change, and accessing the admin menu.
📋 Project Overview
This program simulates an automatic beverage vending machine. The client can choose from four drinks (Café, Thé à la Menthe, Chocolat Chaud, Cappuccino), insert coins (0.10€, 0.20€, 0.50€, 1€, 2€), and receive change. An admin panel (password‑protected) lets the owner view total revenue, number of each drink sold, change the password, or reset statistics. All data is saved to files, so it persists between runs.
✨ Key Features
🧠 Core Logic (Code Snippet)
Below is the main payment loop and structure definition.
typedef struct {
float ca_total;
int v_cafe;
int v_the;
int v_choc;
int v_cap;
} Stats;
// Payment loop example
while(total_insere < prix - 0.001f) {
printf("\nInserez une piece (0.10 / 0.20 / 0.50 / 1 / 2) : ");
scanf("%f", &insere);
if(insere == 0.10 || insere == 0.20 || insere == 0.50 || insere == 1.0 || insere == 2.0) {
total_insere += insere;
// show remaining amount
} else {
printf("[!] Piece refusee.\n");
}
}
// After payment: prepare drink, update stats, save to file
The complete source code includes admin authentication, file I/O, and colourful console output using Windows.h.
🛠 Technologies & Concepts
💡 What I Learned – This project strengthened my understanding of structured programming, persistent data storage, and creating a user‑friendly console interface. I also improved my skills in handling real‑world constraints like coin validation and exact change.