Computer Science, asked by 12ankita9a, 2 months ago

swer any four:
6. An Electricity Board charges for electricity per month from their consumers
according to the units consumed. The tariff is given below:
Units Consumed
Up to 200 units
More than 200 units and up to 300 units
More than 300 units and up to 400 units
Charges
* 3.80/unit
* 4.40/unit
* 5.10/unit
* 5.80/unit
More than 400 units​

Answers

Answered by npdeepthi12
38

Answer:

Program to calculate the electricity bill taking consumer’s name and units consumed as inputs.

Explanation:

A program in C to calculate and print the Electricity bill of a given customer.

#include <stdio.h>

#include <string.h>

int main()

{

  float chg, unit,consume;

  char cust_name[25];

  printf("Input the name of the customer :");

  scanf("%s", cust_name);

  printf("Input the unit consumed by the customer : ");

  scanf("%f",&unit);

  if (unit <200 )

chg = 3.80;

  else if (unit>=200 && unit<=300)

 chg = 4.40;

else if (unit>300 && unit<=400)

  chg = 5.10;

 else

  chg = 5.80;

  consume = unit*chg;

  printf("\nElectricity Bill\n");

  printf("Customer Name                       : %s\n",cust_name);

  printf("unit Consumed                       : %.3f\n",consume);

   return 0;

}

Output

Input the name of the customer :Simran                                                

Input the unit consumed by the customer : 350                                                                                                                                        

Electricity Bill                                                                                       Customer Name                       : Simran                                            

unit Consumed                       : 1785.000

Answered by Equestriadash
41

The following cσdes have been written using Python.

c = "Yes"

while c == "Yes":

   u = float(input("Enter the units consumed: "))

   print()

   if u <= 200:

       print("You will be charged 3.80/unit.")

       tc = 3.80*u

       print(tc, "is your total cost.")

   elif u > 200 and u <= 300:

       print("You will be charged 4.40/unit.")

       tc = 4.40*u

       print(tc, "is your total cost.")

   elif u > 300 and u <= 400:

       print("You will be charged 5.10/unit.")

       tc = 5.10*u

       print(tc, "is your total cost.")

   elif u > 400:

       print("You will be charged 5.80/unit.")

       tc = 5.80*u

       print(tc, "is your total cost.")

   print()

   c = input("Next customer? [Yes/No] : ")

   print()

   if c == "No":

       break

Similar questions