Write a C program to input electricity unit charges and calculate total electricity billaccording to the given condition:For first 50 units Rs. 0.50/unitFor next 100 units Rs. 0.75/unitFor next 100 units Rs. 1.20/unitFor unit above 250 Rs. 1.50/unitAn additional surcharge of 20% is added to the b
Question
Write a C program to input electricity unit charges and calculate total electricity billaccording to the given condition:For first 50 units Rs. 0.50/unitFor next 100 units Rs. 0.75/unitFor next 100 units Rs. 1.20/unitFor unit above 250 Rs. 1.50/unitAn additional surcharge of 20% is added to the b
Solution
Sure, here is a step-by-step solution in C:
- Start by including the necessary header files:
#include <stdio.h>
- Declare the main function:
int main() {
// code goes here
return 0;
}
- Declare the variables to store the electricity unit charges and the total bill:
float units, bill;
- Prompt the user to enter the electricity unit charges:
printf("Enter the electricity unit charges: ");
scanf("%f", &units);
- Calculate the total bill based on the given conditions:
if (units <= 50) {
bill = units * 0.50;
} else if (units <= 150) {
bill = 50 * 0.50 + (units - 50) * 0.75;
} else if (units <= 250) {
bill = 50 * 0.50 + 100 * 0.75 + (units - 150) * 1.20;
} else {
bill = 50 * 0.50 + 100 * 0.75 + 100 * 1.20 + (units - 250) * 1.50;
}
// Add the additional surcharge of 20%
bill += bill * 0.20;
- Display the total electricity bill:
printf("Total electricity bill: Rs. %.2f\n", bill);
- End the program:
return 0;
The complete code will look like this:
#include <stdio.h>
int main() {
float units, bill;
printf("Enter the electricity unit charges: ");
scanf("%f", &units);
if (units <= 50) {
bill = units * 0.50;
} else if (units <= 150) {
bill = 50 * 0.50 + (units - 50) * 0.75;
} else if (units <= 250) {
bill = 50 * 0.50 + 100 * 0.75 + (units - 150) * 1.20;
} else {
bill = 50 * 0.50 + 100 * 0.75 + 100 * 1.20 + (units - 250) * 1.50;
}
bill += bill * 0.20;
printf("Total electricity bill: Rs. %.2f\n", bill);
return 0;
}
This program will calculate the total electricity bill based on the given conditions and display the result.
Similar Questions
Write a program to input the electricity unit consumed and calculate the total electricity bill according to the given conditions: For the first 50 units Rs. 3.50/unit For the next 100 units Rs. 4.50/unit For the next 100 units Rs. 5.20/unit For units above 250 Rs. 6.75/unit An additional surcharge of 20% is added to the bill.Input format :The input consists of the units consumed.Output format :The output prints the final bill amount.Round off the output to two decimal places.Refer to the sample output for formatting specifications.Sample test cases :Input 1 :50Output 1 :210.00Input 2 :150Output 2 :750.00Input 3 :250Output 3 :1374.00Input 4 :300Output 4 :1779.00
Given the number of units consumed by a domestic user in Tamil Nadu, write a program to calculate the electricity bill. The Tamil Nadu electricity bill tariff for domestic user is given belowTamilNadu Electricity BillConsumption upto 500 unitUnits from To Units Unit Cost / KWH 1 100 0 101 200 2.25 201 400 4.50 401 500 6.00Consumption above 500 units 1 100 0 101 400 4.50 401 500 6 501 600 8 601 800 9 801 1000 10Above 1000 units 11 Input Format:Give the number of units consumed:Output Format:Tariff: Sample Input: 400Sample Output:
Ravi wants to estimate the total utility bill for a household based on the consumption of electricity, water, and gas. Write a program to calculate the total bill using the following criteria:The cost per unit for electricity is 0.12, for water is 0.05, and for gas is 0.08.A discount is applied to the total cost based on the following conditions:If the total cost is 100 or more, a 10% discount is applied.If the total cost is between 50 and 99.99, a 5% discount is applied.No discount is applied if the total cost is less than 50.The program should output the total bill after applying the discount with two decimal places.Input format :The input consists of three double values, representing the number of units consumed for electricity, water, and gas respectively.Output format :The output prints a double value, representing the total bill after applying the discount, formatted to two decimal places.Refer to the sample output for formatting specifications.Code constraints :1.00 ≤ units consumed ≤ 10000.00Sample test cases :Input 1 :1000.0200.0100.0Output 1 :124.20Input 2 :500.030.020.0Output 2 :59.95Input 3 :120.070.045.0Output 3 :21.50
To develop a Java application to generate Electricity bill. Create a class with the following members: Consumer no., consumer name, previous month reading, current month reading, type of EB connection (i.e domestic or commercial). Compute the bill amount using the following tariff. If the type of the EB connection is domestic, calculate the amount to be paid as follows:First 100 units - Rs. 1 per unit101-200 units - Rs. 2.50 per unit201 -500 units - Rs. 4 per unit> 501 units - Rs. 6 per unitIf the type of the EB connection is commercial, calculate the amount to be paid as follows:First 100 units - Rs. 2 per unit101-200 units - Rs. 4.50 per unit201 -500 units - Rs. 6 per unit> 501 units - Rs. 7 per unitSample:InputEnter consumer number 1001Enter Type of connection (D for Domestic or C for Commercial) DEnter consumer name SachinEnter previous month reading 3000Enter current month reading 4000OutputConsumer number = 1001Consumer name = Sachintype of connection = DOMESTICCurrent Month Reading = 4000.0Previous Month Reading = 3000.0Total units = 1000.0Total bill = RS 6000.0
Create a class for Electricity for N flats of an apartment. The required details are Flat number, EB meter number, Owner name, Previous month reading (in Units), current month reading (in Units), amount. Amount will be calculating as below:0-100 = Minimum charges ₹100.00101-500 = 2.50 ₹ per unit501-1000 = 5.00 ₹ per unitAbove 1000 =7.50 ₹ per unit Write appropriate functions to perform the following:Display the flat number, owner name, previous reading and current reading.Floor will be identified from the first digit of a flat number. For 1001 – first floor, 2005 – second floor, 5010- Fifth floor. Display the floor wise details with total units and total amount.Input format:Enter the flat No:Enter the flat owner Name:Enter the previous reading:Enter the current reading:Output format:Total Units:Total amount:
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.