| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 405 人关注过本帖
标题:设计好一个程序了,但是要如何用for 死循环整个程序,可以输入第二次各位帮 ...
只看楼主 加入收藏
derrick_goi
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2011-6-6
结帖率:0
收藏
已结贴  问题点数:20 回复次数:2 
设计好一个程序了,但是要如何用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");
            
            
        }
   
   
}
搜索更多相关主题的帖子: 设计 quantity include double 
2011-07-15 10:52
hellovfp
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:禁止访问
威 望:30
帖 子:2976
专家分:7697
注 册:2009-7-21
收藏
得分:20 
把你主程序里的内容放到一个子程序里,然后主程序用for,while死循环之。

我们都在路上。。。。。
2011-07-15 11:33
derrick_goi
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2011-6-6
收藏
得分:0 
回复 2楼 hellovfp
已经做到了,谢谢你
2011-07-15 12:09
快速回复:设计好一个程序了,但是要如何用for 死循环整个程序,可以输入第二次各 ...
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.021046 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved