google.com, pub-6167773875660516, DIRECT, f08c47fec0942fa0 Write a c program to calculate electricity bill - 2nd puc computer science

Write a c program to calculate electricity bill

write a c program to calculate electricity bill using if else,write a program to calculate electricity bill

Write a c program to calculate electricity bill

Units consumed           rate/unit

<30                              3.5

>=30 and <50               4.25

>=50 and <100             5.25

>=100                           5.85

*/

#include<stdio.h>

#include<conio.h>

void main()

{

int oldread, newread,units;

float minamt,vat,amt,netamt;

clrscr();

printf("Enter old reading: ");

scanf("%d",&oldread);

printf("Enter new reading: ");

scanf("%d",&newread);

printf("Enter the minimum fixed amount: ");

scanf("%f",&minamt);

units=newread-oldread;

if(units<30)

amt=units*3.5;

else if(units<50)

amt=(29*3.5)+(units-29)*4.25;

else if(units<100)

amt=(29*3.5)+(20*4.25)+(units-49)*5.25;

else

amt=(29*3.5)+(20*4.25)+(50*5.25)+(units-99)*5.85;

vat=12.5/100.0;

netamt=(amt*vat)+amt+minamt;

printf("Total amount=%f",netamt);

getch();

}

Output:

 

run 1:

Enter old reading: 450

Enter new reading: 600

Enter the minimum fixed amount: 200

Total amount=1040.768677

 

run 2:

Enter old reading: 100

Enter new reading: 120

Enter the minimum fixed amount: 200

Total amount=278.750000

 

run 3:

Enter old reading: 100

Enter new reading: 140

Enter the minimum fixed amount: 200

Total amount=366.781250

 

run 4:

Enter old reading: 100

Enter new reading: 160

Enter the minimum fixed amount: 200

Total amount=474.781250


Write a c program to calculate electricity bill Write a c program to calculate electricity bill Reviewed by Vision Academy on December 18, 2021 Rating: 5

No comments:

CheckOut

Powered by Blogger.