Click here to Skip to main content
15,884,628 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
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:

C
#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();
}
Posted
Updated 28-Sep-21 0:59am
v2

1 solution

Read the instructions again: it specifically tells you which functions to use - that code doesn't use them at all.

That looks like you found something similar on the internet and want it modified so you can hand it in as your own work: if so, that isn't going to happen. While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900