-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBilling_System.c
More file actions
66 lines (57 loc) · 1.9 KB
/
Billing_System.c
File metadata and controls
66 lines (57 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*1. Build a Billing System for a small store.
> - Using control statements to loop through items, take input, calculate total + discount.
> - Display final bill with tax and itemized list.
Developed by Amina Hasanaath*/
#include<stdio.h>
#include<string.h>
int main(){
printf("=====================DMART MALL===================\n");
printf("\t \tWelcome to our store!\t");
char items[100][100];
int total_items;
int amt[100];
float disc[100];
float total_amt;
float total_discount;
float tax;
printf("\nEnter the total number of items purchased:\t");
scanf("%d",&total_items);
getchar();
for(int i =0;i<total_items;i++){
printf("item[%d]: ",i+1);
fgets(items[i],sizeof(items[i]),stdin);
printf("Enter amount: \t");
scanf("%d",&amt[i]);
getchar();
printf("Enter discount: \t");
scanf("%f",&disc[i]);
getchar();
printf("\n");
}
printf("The items are :");
for(int i =0;i<total_items;i++){
printf("\nitem[%d] : \t\t%s",i+1,items[i]);
printf("amount paid [%d]: \t%d ",i+1,amt[i]);
printf("\n");
printf("discount paid [%d] : \t%0.2f" ,i+1,disc[i]);
printf("\n");
}
for(int i =0;i<total_items;i++){
total_amt+=amt[i];
}
printf("\nTotal amount : %0.2f", total_amt);
for(int i =0;i<total_items;i++){
total_discount += disc[i];
}
printf("\nTotal discount: %0.2f", total_discount);
total_amt -= total_discount;
//printf("\n\nThe payment :%0.2f",total_amt);
printf("\nEnter the tax : \t");
scanf("%f",&tax);
printf("\nTax : %0.2f",tax);
total_amt += tax;
printf("\nTotal bill: \t%0.2f",total_amt);
printf("\n\n\t=========THANKYOU FOR VISITING=========\t");
printf("\n\t============Visit Again===============");
printf("\n=======================DMART MALL=====================");
}