Write a program that asks a customer to enter the number of consumed electricity units. The program then calculates and prints the electricity bill without VAT, and then prints it with VAT knowing that:

  • For the first 50 consumed units, the customer pays 0.50\$ per unit,
  • for the units consumed beyond 50, the customer pays 0.75\$ per unit,
  • the VAT is equal to 11%.

Difficulty level
Video recording
This exercise is mostly suitable for students
#include<stdio.h>
#include<conio.h>
main() {
	int unit;
	float  total_amt_without_vat, total_amt_with_vat;

	printf("Enter the number of consumed electricity units: ");
	scanf("%d", &unit);

	if (unit <= 50) {
		total_amt_without_vat = unit * 0.50;
	}
	else {
		total_amt_without_vat = 25 + ((unit - 50) * 0.75);
	}

	total_amt_with_vat = total_amt_without_vat + total_amt_without_vat*0.11;

	printf("Electricity Bill without VAT = %.2f $\n", total_amt_without_vat);
	printf("Electricity Bill with VAT = %.2f $", total_amt_with_vat);
	getch();
}

Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Sorting an array by minimum selection