#include #include int getinput(); float calcDiscount(int utilities,float amountpay,int typebill); void calcTotalpaid(float amountpay ,float discount,float *totaldiscount, float *totalpaid); void display(float totalpaid); int main() { int counter=1; float totalpaid; while (counter!=0) { int typebill,utilities,internet; float amountpay = 0,totaldiscount,discount; typebill=getinput(); if (typebill==1) { printf("Enter 1=TNB or 2=SYABAS : "); scanf("%d",&utilities); } else if(typebill==2) { printf("Enter 1=DIGI 2=UNIFI or 3=MAXIS FIBRE:"); scanf("%d", &internet); } fflush(stdin); printf("\nEnter amount to pay : "); scanf(" %f",&amountpay); discount= calcDiscount( utilities, amountpay, typebill); calcTotalpaid(amountpay ,discount,&totaldiscount,&totalpaid); printf("\nTotal after discount = RM%.2f",totaldiscount); printf("\nContinue? 1=yes, 0=no: "); scanf("%d", &counter); } display(totalpaid); return 0; } int getinput() { int typebill; printf("\nEnter bill type (1=utilities, 2=internet): "); scanf("%d",&typebill); return typebill; } float calcDiscount(int utilities,float amountpay,int typebill) { float discount; int internet; if (typebill==1) { if (utilities==1) { discount=0.05; } else { discount=0.1; } } else { if (typebill==2) { if (internet==1) { discount=0.05; } else if (internet==2) { discount=0.05; } else { discount=0.05; } } } return discount; } void calcTotalpaid(float amountpay ,float discount,float *totaldiscount, float *totalpaid) { *totaldiscount= amountpay*(1-discount); *totalpaid= *totalpaid + *totaldiscount; } void display(float totalpaid) { printf("\nTotal paid : RM %.2f", totalpaid); printf("\nThank You for using TickNGo"); }