设计好一个程序了,但是要如何用for 死循环整个程序,可以输入第二次各位帮忙下,谢谢
#include <stdio.h>#include <math.h>
void main()
{
int receipt_no,total=0;
double quantity, quantityA, quantityB, quantityC, voucher,amountA, amountB, amountC, total_amount;
double comboA=10.20, comboB=22.20, comboC=34.20, gov_tax, ser_tax,sub_total_Amount,cash,change_due;
double discount10, discount05, discount0,amount_pay,adj_amount_pay;
printf("\n\n");
printf ("\n\t @@ @@@ @@@@@@@@ @@@@@@@@@@ ");
printf ("\n\t @@ @@ @@ @@@ @@ ");
printf ("\n\t @@@@@ @@@@@@@ @@@ ");
printf ("\n\t @@ @@ @@ @@@ @@ ");
printf ("\n\t @@ @@@ @@ @@@@@@@@@@ \n");
printf("\n\t ~~GOOD DAY AND WELCOME TO KLFC SDN BHD~~ \n\n");
printf ("Please Enter the Quantity of Combo Set A : ");
scanf ("%lf", &quantityA);
printf ("Please Enter the Quantity of Combo Set B : ");
scanf ("%lf", &quantityB);
printf ("Please Enter the Quantity of Combo Set C : ");
scanf ("%lf",&quantityC);
printf ("Please Enter your voucher : ");
scanf ("%lf",&voucher);
amountA = quantityA * comboA;
amountB = quantityB * comboB;
amountC = quantityC * comboC;
total_amount = amountA+amountB+amountC;
gov_tax = total_amount * 0.06;
ser_tax = total_amount * 0.10;
sub_total_Amount = total_amount + gov_tax + ser_tax;
printf("\n +=====================================================+");
printf("\n | DESCRIPTION | RATE | AMOUNT |");
printf("\n +=====================================================+\n");
if (quantityA>=1)
printf(" | Combo A *%.0lf | 10.20 | %.2lf |\n",quantityA,amountA);
if (quantityB>=1)
printf(" | Combo B *%.0lf | 22.20 | %.2lf |\n",quantityB,amountB);
if (quantityC>=1)
printf(" | Combo C *%.0lf | 34.20 | %.2lf |\n",quantityC,amountC);
printf(" | Government Tax | 6%% | %.2lf |\n",gov_tax);
printf(" | Service Tax | 10%% | %.2lf |",ser_tax);
printf ("\n +=====================================================+");
printf ("\n | S U B T O T A L | | %.2lf |",sub_total_Amount);
printf ("\n +=====================================================+");
printf ("\n");
if(voucher==0)
{
if(sub_total_Amount>=120)
{
printf(" |Get Free a member card |\n");
discount10 =sub_total_Amount * 0.10;
printf(" |\t Discount 10%% (RM) %.2lf |\n",discount10);
printf(" |\t\t\t -------- |\n");
amount_pay=sub_total_Amount-discount10;
printf(" |\t Amount Payable\t(RM) %.2lf |\n",amount_pay);
printf(" |\t\t\t========== |\n");
adj_amount_pay=floor(amount_pay*20+0.5)/20;
}
if(sub_total_Amount<120 && sub_total_Amount>=50)
{
printf(" |\t Free 1 Combo Set |\n");
discount05 =sub_total_Amount * 0.05;
printf(" |\t Discount 5%% (RM) %.2lf |\n",discount05);
printf(" |\t\t\t -------- |\n");
amount_pay=sub_total_Amount-discount05;
printf(" |\t Amount Payable\t(RM) %.2lf |\n",amount_pay);
printf(" |\t\t\t========== |\n");
adj_amount_pay=floor(amount_pay*20+0.5)/20;
}
if(sub_total_Amount<50)
{
printf(" |\t Get Free 1 Drink |\n");
discount0=sub_total_Amount;
printf(" |\t No Discount |\n");
printf(" |\t\t\t --------\n");
amount_pay=sub_total_Amount-discount0;
printf(" |\t Amount Payable\t(RM) %.2lf |\n",amount_pay);
printf(" |\t\t\t========== |\n");
adj_amount_pay=floor(amount_pay*20+0.5)/20;
}
}
else if(voucher!=0)
{
printf(" |\t Voucher:\t(RM) %.2lf |\n",voucher);
printf(" |\t Discount\t(RM) 0.00% |\n");
printf(" |\t\t\t -------- |\n");
amount_pay =sub_total_Amount-voucher;
printf(" |\t Amount Payable\t(RM) %.2lf |\n",amount_pay);
printf(" |\t\t\t========== |\n");
adj_amount_pay=floor(amount_pay*20+0.5)/20;
}
printf (" |\t Adjusted Amount Payable\t\t%.2lf |\n",adj_amount_pay);
printf (" +=====================================================+\n");
quantity=quantityA+quantityB+quantityC;
printf (" | Total Combo set ordered:\t%.0lf |\n",quantity);
printf (" |\t\tCASH >>\t |");
scanf ("%lf",&cash);
change_due=cash-adj_amount_pay;
printf(" |\t\tCHANGE DUE \t %.2lf |",change_due);
printf ("\n+=====================================================+\n");
printf ("\t ~~~THANK YOU AND HAVE A NICE DAY~~~ \n\n");
}
}