"""DEMO: corrected implementation, provided with regression tests."""


def discounted_total(subtotal: float, percent: float) -> float:
    if subtotal < 0:
        raise ValueError("subtotal must be non-negative")
    if not 0 <= percent <= 100:
        raise ValueError("percent must be between 0 and 100")
    return round(subtotal * (1 - percent / 100), 2)
