Question

Bills Management System in C Programming consist of the electricity bills, water bills, phone bills need...

Bills Management System in C Programming

  • consist of the electricity bills, water bills, phone bills
  • need to state the unit that being used
  • also can present the previous payment
  • amount that need to pay, arrears, change etc.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<conio.h>


#include<stdio.h>


#include<stdlib.h>


#define TotalCustomers 50 //Maximum Customers

//Structure to define a customer


struct customers{


   char name[50]; //name of customer


   int customerId; //Id of customer


   float units; //units used


   float amount; //total amount


};


int main(){


   int ch1,ch2; //Stores choices of main menu and sub menu


   int cid0=0,cid1=0,cid2=0;//Used to generate auto customer id for electricity,water,phone


   int cidtemp;//reads temp customer id


   struct customers cus[3][TotalCustomers];//creates a 2d array of type struct customer

/*cus[0][] for electricity ,cus[1][] for water ,cus[2][] for phone */


   do{

//main Menu


       printf("\n----------------------------Bill Management System-------------------------------\n");


       printf("\n1.Electricity Bill\n");


       printf("\n2.Water Bill\n");


       printf("\n3.Phone Bill\n");


       printf("\n0.Exit\n");


       scanf("%d",&ch1);//reads choice of main menu


       switch(ch1){


           case 0:


               exit(0);//terminates program execution


           case 1:


               do


               {

//sub menu
               printf("\n-------------------------------Electricity Bill--------------------------------\n");


               printf("\n\t\t1.Enter a new customer\n");


               printf("\n\t\t2.View Bill\n");


               printf("\n\t\t0.Exit\n");


               scanf("%d",&ch2); //reads submenu choice


               switch(ch2){


                   case 0:
                      


                   exit(1);


                   case 1:
                  


                       cus[0][cid0].customerId=cid0+1;//sets the customer id


                       printf("\n\t\t\tEnter your name : ");


                       fflush(stdin);//clear input buffer


                       gets(cus[0][cid0].name);//reads name


                       printf("\n\t\t\tEnter the units used : ");


                       scanf("%f",&cus[0][cid0].units);//reads unit used


                       cus[0][cid0].amount=cus[0][cid0].units*12.0; //calculate total amount ,12.0 per unit


                       printf("\n\t\t\tCustomer added : \t customer id : %d\n",cid0+1);


                       cid0++;//increment customer id for next customer


                       break;


                   case 2:


                       printf("\n\t\t\tEnter your customer id [1-50] : ");


                       scanf("%d",&cidtemp);//reads customer id

//Then it prints the bill


                       printf("\n\t\t\t\tYour Bill \n");


                       printf("\n\t\t\tName : ");

//cidtemp-1 is used because index starts fro zero


                       puts(cus[0][cidtemp-1].name);


                       printf("\n\t\t\t");


                       printf("Customer Id : %d \n",cus[0][cidtemp-1].customerId);


                       printf("\n\t\t\tUnit Consumed : %f units \n",cus[0][cidtemp-1].units);


                       printf("\n\t\t\tTo be paid : Rs.%f \n",cus[0][cidtemp-1].amount);


                       break;

default:


                       printf("\n\t\t\tEnter a valid Choice [0-2]\n");


                      
               }
              


           }while(1);


           break;
          
           case 2:


               do

{

//working same as above


printf("\n-------------------------------Water Bill--------------------------------\n");


               printf("\n\t\t1.Enter a new customer\n");


               printf("\n\t\t2.View Bill\n");


               printf("\n\t\t0.Exit\n");


               scanf("%d",&ch2);


               switch(ch2){


                   case 0:


                       exit(1);


case 1:


                       cus[1][cid1].customerId=cid1+1;


                       printf("\n\t\t\tEnter your name : ");


                       fflush(stdin);


                       gets(cus[1][cid1].name);


                       printf("\n\t\t\tEnter the units used : ");


                       scanf("%f",&cus[1][cid1].units);


                       cus[1][cid1].amount=cus[1][cid1].units*5.0;//rate per unit is 5.0


                       printf("\n\t\t\tCustomer added : \t customer id : %d\n",cid1+1);


                       cid1++;


                       break;


                   case 2:

//working same as above


                       printf("\n\t\t\tEnter your customer id [1-50] : ");


                       scanf("%d",&cidtemp);


                       printf("\n\t\t\t\tYour Bill \n");


                       printf("\n\t\t\tName : ");


                       puts(cus[1][cidtemp-1].name);


                       printf("\n\t\t\t");


                       printf("Customer Id : %d \n",cus[1][cidtemp-1].customerId);


                       printf("\n\t\t\tUnit Consumed : %f units\n",cus[1][cidtemp-1].units);


                       printf("\n\t\t\tTo be paid : Rs.%f \n",cus[1][cidtemp-1].amount);


                       break;


                   default :


                       printf("\n\t\t\tEnter a valid Choice [0-2]\n");


                      
               }


           }while(1);


           break;
          


           case 3:


               do


               {

//working same as above


               printf("\n-------------------------------Electricity Bill--------------------------------\n");


               printf("\n\t\t1.Enter a new customer\n");


               printf("\n\t\t2.View Bill\n");


               printf("\n\t\t0.Exit\n");


               scanf("%d",&ch2);


               switch(ch2){


                   case 0:


                       exit(1);


                   case 1:
                  


                       cus[2][cid2].customerId=cid2+1;


                       printf("\n\t\t\tEnter your name : ");


                       fflush(stdin);


                       gets(cus[2][cid2].name);


                       printf("\n\t\t\tEnter the units used : ");


                       scanf("%f",&cus[2][cid2].units);


                       cus[2][cid2].amount=cus[2][cid2].units*6.0;//rate per unit is 6.0


                       printf("\n\t\t\tCustomer added : \t customer id : %d\n",cid2+1);


                       cid2++;


                       break;


                   case 2:


                       printf("\n\t\t\tEnter your customer id [1-50] : ");


                       scanf("%d",&cidtemp);


                       printf("\n\t\t\t\tYour Bill \n");


                       printf("\n\t\t\tName : ");


                       puts(cus[2][cidtemp-1].name);


                       printf("\n\t\t\t");


                       printf("Customer Id : %d \n",cus[2][cidtemp-1].customerId);


                       printf("\n\t\t\tUnit Consumed : %f units\n",cus[2][cidtemp-1].units);


                       printf("\n\t\t\tTo be paid : Rs.%f \n",cus[2][cidtemp-1].amount);


                       break;


                   default :


                       printf("\n\t\t\tEnter a valid Choice [0-2]\n");
                      


               }


           }while(1);


           break;


       default :


       printf("\nEnter a valid choice [0-3] \n");     


       }
      


   }while(1);


}

Add a comment
Know the answer?
Add Answer to:
Bills Management System in C Programming consist of the electricity bills, water bills, phone bills need...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • computer programming Write a C program that will calculate and print monthly water bills. The total...

    computer programming Write a C program that will calculate and print monthly water bills. The total units consumed per month are derived from subtracting the previous meter readings with the current meter reading. The charges are calculated based on the rates stated in Table 2. The sample output is shown in Figure 16 Tulis aturcara Cyang akan mengira dan mencetak bil air bulanan Jumlah unit yang diguna sebulan dikira dengan menolak bacaan meter sebelum dengan bacaan meter terkinl. Caj dikira...

  • In this assignment, you will implement a Memory Management System(MMS). Using C Programming Language..... MAKE SURE...

    In this assignment, you will implement a Memory Management System(MMS). Using C Programming Language..... MAKE SURE YOU USE C PROGRAMMING Your MMS will handle all requests of allocation of memory space by different users (one thread per user) …. HINT(You will use Pthreads and Semaphores). Your MMS will provide the user with an interface for making memory requests and also for freeing up memory that is no longer needed by the user. One of the jobs of your memory management...

  • Please need serious and professional help! Hello! I am working on an "object oriented analysis and...

    Please need serious and professional help! Hello! I am working on an "object oriented analysis and design" Project. I would really need your sincere help in creating a vision document for this project. The Things That I require in the "vision document" is: 1. Product Overview [This section provides a high level view of the product capabilities, interfaces to other applications, and system configurations. This section usually consists of three subsections, as follows: •          Product perspective •          Product functions •         ...

  • C++ need help programming something like this? This project will help you show your mastery of...

    C++ need help programming something like this? This project will help you show your mastery of arrays, C-strings, classes, and libraries. Write a program to handle a user's rolodex entries. (A rolodex is a system with tagged cards each representing a contact. It would contain a name, address, and phone number. In this day and age, it would probably have an email address as well.) Typical operations people want to do to a rolodex entry are: 1) Add entry 2)...

  • I need help how can I answers A, B , C , D 8.9 、bottled water...

    I need help how can I answers A, B , C , D 8.9 、bottled water distributor wants to estimate the amount of rwater contained in 1-gallon bottles purchased from a nationally known water bottling company. The water bottling company's specifications state that the standard deviation of the amount oft water is equal to o0.02 gallon. A random sample of 50 bottles is selected, and the sample mean amount of water per I-gallon bottle is 0.995 gallon. a. Construct a...

  • Future Value and Present Worth (DRAW the Cash Flow Diagram) a) MARTA is buying a new...

    Future Value and Present Worth (DRAW the Cash Flow Diagram) a) MARTA is buying a new ticketing system. The price the vendor and MARTA has agreed to is $200,000. The city will also pay 8% interest compounded annually for the ability to not make any payment on the system until the 5 year warranty period is up. So, the agency is going to install the new system in December 2018 but they do not have to pay the vendor until...

  • Problem 7. Unit Analysis and Engineering Design You have been hired to analyze the university's water...

    Problem 7. Unit Analysis and Engineering Design You have been hired to analyze the university's water usage. Much of the water used on campus goes toward irrigation. The only athletic field at Angelo State that requires irrigation is the soccer field. The daily irrigation demand, D in gal/day, can be calculated as ET,x F,x Ax0.62 D- E Where D-demand in gal/day ETo-Evapotranspiration factor (0.23 in San Angelo) Fp= Plant factor (ranges from 0.3 to 1.0 depending on type of plants...

  • C programming Construct a console program to simulate Zoo ticketing system. The system is used for...

    C programming Construct a console program to simulate Zoo ticketing system. The system is used for dispensing tickets to customers. In order to buy tickets, the customer need to enter the following information: a) Number of ticket they want to buy. Everybody must have a ticket to enter. b) Only up to 5 tickets may be purchased for every transaction or customer. c) Type of ticket either for adult, children (aged 5 12 years old) or toddler (aged 2-5 years...

  • 1. Create a new multi-class Java program which implements a vending machine simulator which contains the...

    1. Create a new multi-class Java program which implements a vending machine simulator which contains the following functionality: A) At program startup, the vending machine is loaded with a variety of products in a variety of packaging for example soda/tonic/Coke in bottles, peanuts in bags, juice in cartons, etc. Also included is the cost of each item. The program should be designed to easily load a different set of products easily (for example, from a file). Also at program startup,...

  • Please only use c programming to solve this project. Feel free to ask anything, however, all...

    Please only use c programming to solve this project. Feel free to ask anything, however, all details have been provided so read the text carefully. Introduction Retail stores have been using cashier machines for almost a century to prepare bills in order to provide detail information to their customers about their purchase. In the past couple of decades, cashier machines have been replaced by computers and appropriate software known as Point of Sales (POS) with advanced capabilities varying from stock-taking...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT