Vending Machine State Controller

Medium Applied C++ OOP Mini Projects
Solve in Playground →

Problem Statement

Model a `VendingMachine` handling `balance` and `price`. Accept deposit commands (`DEPOSIT x`), purchase (`BUY`), or refund (`REFUND`). Print final balance or item status directly.

Input Format

Line 1: item price P. Line 2: N commands.

Output Format

Print final balance float (2 decimals) or 'DISPENSED' / 'INSUFFICIENT' / 'REFUNDED'.

Constraints

P > 0, N >= 1

Sample Input

2.00
3
DEPOSIT 1.00
DEPOSIT 1.00
BUY

Sample Output

DISPENSED

Explanation

Deposited 2.00 matches price 2.00, item is dispensed.

Starter Code

#include <iostream>
#include <string>

class VendingMachine {
public:
    // Write your code here
};

int main() {
    // Implement I/O logic here
    return 0;
}

Limits

  • Time Limit: 1s
  • Memory Limit: 256MB

Embedded C Programming

Updated: March 15, 2026
Intermediate

Embedded systems rely on efficient low-level programming to interact directly with hardware. In this course, you will learn how to write practical Embedded C programs used in real microcontroller-based systems. Rather than focusing only on theory, this course follows a practice-driven approach. Each lesson includes hands-on coding exercises that simulate real firmware development tasks used