Write a program that will calculate and show bills of the Electric Company. The rates vary depending on whether the use is residential (R), commercial( C) , or industrial (I). Any other code should be treated as an error.
The program should accept the subscriber ID, Subscriber Name, his total electrical consumption in a month, and the code of the consumer type.
The rates are computed as follows:
R: 50 plus .50 per kwh used
C: 100 for the first 1000 kwh and 0.45 for each additional kwh
I: 180 for the first 1000 kwh and 0.75 for each additional kwh
please use ,
#include<stdio.h>
#include<conio.h>
and,
scanf:
printf
thank you..
What I have tried:
#include<stdio.h>
#include<conio.h>
main()
{
clrscr();
float kwh,total;
char id,name[100],code;
gotoxy(22, 3); cprintf("MERALCO Electric Bill Statement");
textcolor(6);
gotoxy(21, 6);cprintf("Enter Subscriber Name : ");
textcolor(3);
gets(name);
textcolor(6);
gotoxy(21, 8);cprintf("Enter Subscriber ID : ");
textcolor(3);
gotoxy(53, 8); cscanf("%d",&id);
textcolor(6);
gotoxy(21, 10);cprintf("Enter Total Consumption in KWH:");
textcolor(3);
gotoxy(53, 10); cscanf("%f",&kwh);
textcolor(6);
gotoxy(21, 12);cprintf("Enter Consumer Code (R/C/I) : ");
textcolor(3);
code=getche();
switch (code)
{
case 'R': case 'r':
{
total=50+(kwh*0.5);
break;
}
case 'C': case 'c':
{
if (kwh<=1000)
{
total=100;
break;
}
total=100+((kwh-1000)*0.45);
break;
}
case 'I': case 'i':
{
if (kwh<=1000)
{
total=180;
break;
}
total=180+((kwh-1000)*0.75);
break;
}
default:
{
textcolor(9);
gotoxy(25, 17);cprintf("Invalid Input!!!");
gotoxy(25, 18);cprintf("Enter Correct Consumer Code");
break;
}
textcolor(9);
gotoxy(25, 15);cprintf("Kindly see below billing statement");
gotoxy(25, 16);cprintf("Subscriber Name:",name);
gotoxy(25, 17);cprintf("Subscriber ID :",id);
gotoxy(25, 18);cprintf("Consumer Code:",code);
gotoxy(25, 19);cprintf("Total Consumption: %.2f",kwh);
gotoxy(25, 20);cprintf("Total Amount: %.2f",total);
}
getch();
getch();
}