I can't align the table and don't know how to round up the adjusted amount payable.. I tried everything on earth.. Any expert can teach me the solution? TT
Code:#include <stdio.h> #include <math.h> int main (void) { // Variable declaration int combosetCount, discountVoucher; int a = 37; float amount, amountPayable, cash, changeDue, governmentTax, serviceTax, subTotal, adjustedAmount, priceCombo; // Prompt and read the value that entered by user printf("Enter the number of combo set : "); scanf("%d\a", &combosetCount); printf("Enter the price per combo set : RM"); scanf("%f\a", &priceCombo); printf("Enter the discount voucher : RM"); scanf("%d\a", &discountVoucher); printf("Enter Cash : RM"); scanf("%f\a", &cash); // Calculation amount = priceCombo * combosetCount; governmentTax = amount * 6 / 100; serviceTax = amount * 10/100; subTotal = amount + governmentTax + serviceTax; amountPayable = subTotal - discountVoucher; adjustedAmount = ceilf(amountPayable * 100) / 100; changeDue = cash - adjustedAmount; // Combine the results and display the results printf(" ==========\n"); printf(" | KLFC |\n"); printf(" ==========\n"); printf(" Good Day and Welcome to KLFC Sdn. Bhd\n\n"); printf(" R E C E I P T \n"); printf("+-------------------------------+----------+----------------+\n"); printf("| Description | Rate | Amount(RM) |\n"); printf("+-------------------------------+----------+----------------+\n"); printf("| COMBO SET * %3d | %3.2f | %4.2f |\n", combosetCount, priceCombo, amount); printf("| Government Tax | 6%c | %4.2f |\n", a, governmentTax); printf("| Service Tax | 10%c | %4.2f |\n", a, serviceTax); printf("+-------------------------------+----------+----------------+\n"); printf("| S U B T O T A L | %-4.2f |\n", subTotal); printf("+==========================================+================+\n"); printf("| Discount Voucher (RM) %5.2d |\n", discountVoucher); printf("| ------- |\n"); printf("| Amount Payable %4.2f |\n", amountPayable); printf("| ======= |\n"); printf("| Adjusted Amount Payable %-4.2f |\n",adjustedAmount); printf("+===========================================================+\n"); printf(" CASH %3.2f \n", cash); printf(" CHANGE DUE %3.2f \n", changeDue); printf("=============================================================\n\n"); printf(" THANK YOU and HAVE A NICE DAY \n"); return 0; }



2Likes
LinkBack URL
About LinkBacks




CornedBee