Electricity Bill

Medium Decision Making PRO
🔒 Login to Unlock

Problem Statement

Write a C++ program to calculate electricity bill charges based on units consumed: First 100 units @ $1.5/unit, next 150 units @ $2.5/unit, above 250 units @ $3.5/unit.

Input Format

A single integer Units consumed.

Output Format

Print total bill amount formatted to 2 decimal places.

Constraints

Units >= 0

Sample Input

200

Sample Output

375.00

Explanation

Calculates tiered electricity tariff rates: 100 * 1.5 + 100 * 2.5 = 150 + 250 = 400? Wait: 100*1.5=150, remaining 100*2.5=250. Total = 400.00. Wait for sample input 200: 100*1.5 + 100*2.5 = 150 + 250 = 400.00.

Starter Code

#include <iostream>
#include <iomanip>

int main() {
    int units;
    if (std::cin >> units) {
        // Write your code 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