An electricity board charges the following rates for the use of electricity:
For the First 200 units: 80 P per unit
For the Next 100 units: 90 P per unit
Beyond 300 units: Rs. 1.00 per unit
All users are charged a minimum of Rs. 100 as meter charge. If the total amount is more than Rs. 400, then an additional surcharge of 15% of total amount is charged. Write a program to read the names of users and number of units consumed and print out the charges with names.
#include <stdio.h>
void main()
{
char name[10];
float unit, charge;
clrscr();
printf("Enter your name and unit Consumed:");
scanf("%s %f",&name,&unit);
if(unit<125)
charge=100;
else if(unit<=200)
charge=unit*.80;
else if(unit<=300)
charge=(unit-200)*0.90+160;
else
if(unit>300)
charge=(unit-300)*1+250;
if(charge>=400)
charge=charge+charge*0.15;
printf("Name: %s\nCharge: %5.2f",name,charge);
getch();
}
For the First 200 units: 80 P per unit
For the Next 100 units: 90 P per unit
Beyond 300 units: Rs. 1.00 per unit
All users are charged a minimum of Rs. 100 as meter charge. If the total amount is more than Rs. 400, then an additional surcharge of 15% of total amount is charged. Write a program to read the names of users and number of units consumed and print out the charges with names.
#include <stdio.h>
void main()
{
char name[10];
float unit, charge;
clrscr();
printf("Enter your name and unit Consumed:");
scanf("%s %f",&name,&unit);
if(unit<125)
charge=100;
else if(unit<=200)
charge=unit*.80;
else if(unit<=300)
charge=(unit-200)*0.90+160;
else
if(unit>300)
charge=(unit-300)*1+250;
if(charge>=400)
charge=charge+charge*0.15;
printf("Name: %s\nCharge: %5.2f",name,charge);
getch();
}
Thank you alot
ReplyDeleteðŸ˜ðŸ˜ðŸ˜ðŸ˜ðŸ˜
Y that 160 is taken in 2nd else if statement
ReplyDelete