├── README.md └── restaurantBilling.c /README.md: -------------------------------------------------------------------------------- 1 | # billing_system -------------------------------------------------------------------------------- /restaurantBilling.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | struct items{ 6 | char item[20]; 7 | float price; 8 | int qty; 9 | }; 10 | 11 | struct orders{ 12 | char customer[50]; 13 | char date[50]; 14 | int numOfItems; 15 | struct items itm[50]; 16 | }; 17 | //functions to generate biils 18 | void generateBillHeader(char name[50],char date[30]){ 19 | printf("\n\n"); 20 | printf("\t ADV. Restaurant"); 21 | printf("\n\t -----------------"); 22 | printf("\nDate:%s",date); 23 | printf("\nInvoice To: %s",name); 24 | printf("\n"); 25 | printf("---------------------------------------\n"); 26 | printf("Items\t\t"); 27 | printf("Qty\t\t"); 28 | printf("Total\t\t"); 29 | printf("\n---------------------------------------"); 30 | printf("\n\n"); 31 | } 32 | void generateBillBody(char item[30],int qty, float price){ 33 | printf("%s\t\t",item); 34 | printf("%d\t\t",qty); 35 | printf("%.2f\t\t",qty * price); 36 | printf("\n"); 37 | } 38 | 39 | 40 | 41 | void generateBillFooter(float total){ 42 | printf("\n"); 43 | float dis = 0.1*total; 44 | float netTotal=total-dis; 45 | float cgst=0.09*netTotal,grandTotal=netTotal + 2*cgst;//netTotal + cgst + sgst 46 | printf("---------------------------------------\n"); 47 | printf("Sub Total\t\t\t%.2f",total); 48 | printf("\nDiscount @10%s\t\t\t%.2f","%",dis); 49 | printf("\n\t\t\t\t-------"); 50 | printf("\nNet Total\t\t\t%.2f",netTotal); 51 | printf("\nCGST @9%s\t\t\t%.2f","%",cgst); 52 | printf("\nSGST @9%s\t\t\t%.2f","%",cgst); 53 | printf("\n---------------------------------------"); 54 | printf("\nGrand Total\t\t\t%.2f",grandTotal); 55 | printf("\n---------------------------------------\n"); 56 | } 57 | int main(){ 58 | 59 | int opt,n; 60 | struct orders ord; 61 | struct orders order; 62 | char saveBill = 'y',contFlag = 'y'; 63 | char name[50]; 64 | FILE *fp; 65 | //dashboard 66 | while(contFlag == 'y'){ 67 | system("clear"); 68 | float total = 0; 69 | int invoiceFound = 0; 70 | printf("\t============ADV. RESTAURANT============"); 71 | printf("\n\nPlease select your prefered operation"); 72 | printf("\n\n1.Generate Invoice"); 73 | printf("\n2.Show all Invoices"); 74 | printf("\n3.Search Invoice"); 75 | printf("\n4.Exit"); 76 | 77 | printf("\n\nYour choice:\t"); 78 | scanf("%d",&opt); 79 | fgetc(stdin); 80 | switch(opt){ 81 | case 1: 82 | system("clear"); 83 | printf("\nPlease enter the name of the customer:\t"); 84 | fgets(ord.customer,50,stdin); 85 | ord.customer[strlen(ord.customer)-1] = 0; 86 | strcpy(ord.date,__DATE__); 87 | printf("\nPlease enter the number of items:\t"); 88 | scanf("%d",&n); 89 | ord.numOfItems = n; 90 | for(int i=0;i