| վҳ | ҵ | С | | ˲ | Ƶ | | | ߱ | ̳
ӭǣһͬд輼
û   
 
ܡ룺  
863 ˹ע
ĿǰΪֹдij...Ȼܼ...
ֻ¥ ղ
Ryker
Rank: 6Rank: 6
ȡ֮
1
ӣ145
רҷ֣420
ע᣺2013-2-19
ʣ100%
ղ
 0 ظ7 
ĿǰΪֹдij...Ȼܼ...
/* д, ҪһеĹСʱ,Ȼӡܶ,˰Լ

 * ¼:

 * a. ʵȼ            ʹswitchѡʵȼ 

 *        1. 8.75Ԫ/Сʱ

 *        2. 9.33Ԫ/Сʱ

 *        3. 10.00Ԫ/Сʱ

 *        4. 11.20Ԫ/Сʱ
  

 * b. Ӱ (40Сʱ) = 1.5 ʱ

 * c. ˰

 *            ǰ300ԪΪ15%
             һ 150 ԪΪ20%
            µΪ25%
*/

 
/*Ŀ: ӡܶ,˰, */

/*
: 
ûʵȼ
жǷЧ
Ч:(ؼ)
Ч: 
ûÿܹСʱ
жǷ
()
 

 : ʵȼ * Сʱ 
Ӱ : + ((Сʱ - 40) * 1.5)
ܹ =  + Ӱ 

˰: 
0 < ܹ < 300, ˰: ܹ * 0.15
300 < ܹ < 450 һ˰: ˰ + (ܹ - 300) * 0.20
ܹ > 450 : ˰ + һ˰ + (ܹ - 450) * 0.25

ӡ ܶ, ˰ ,  
*/ 
#include <stdio.h>

#define BASE_T 40                //ʱ 
#define OVER_T 1.5F                //Ӱʱ䱶  
#define RATE1 0.15F                //һ˰ 
#define RATE2 0.20F                //ڶ˰ 
#define RATE3 0.25F                //˰
#define TAX1 300                //ڶ˰
#define TAX2 450                //˰ 
#define BASE_TAX1 (TAX1 * RATE1)    //һ˰ֵ 
#define BASE_TAX2 ((TAX2-TAX1) * RATE2)    //ڶ˰ֵ 

void menu(void);

int main(void)
{
    float salary;    //ܶ
    float tax;        //˰ 
    int hour;            //ÿܹСʱ
    char select;            //˵ѡ
    float BASE_D;        //ÿСʱ 
    int flag = 1;
    
    menu();    //ӡ˵ 
    while(flag) 
    {
        select = getchar();
        
        while(getchar() != '\n')        //ջ 
            continue;
    
        switch(select)                        //ѡ˰ 
        {
            case '1':BASE_D = 8.75F; break;    
            case '2':BASE_D = 9.33F; break;
            case '3':BASE_D = 10.00F; break;
            case '4':BASE_D = 11.20F; break;
            case '5':flag = 5; break;            
            default:flag = 0;
        }
        if(flag == 5) break;            //ѡ 5 ˳ 
        
        if(!flag)
        {
            flag = 1;
            printf("Please enter a number between 1~5 : ");
            continue;
        }
        printf("Input the weekly working time(hours): ");
        while(scanf("%d", &hour) != 1)        //ûÿܹʱ
        {
            printf("Invalid character.\nPlease enter a number: ");    //
             
            while(getchar() != '\n')        //ջ 
                continue;
            
        }
        salary = 0;        //ܶ 
        tax = 0;        //˰ 
        
        if(hour < BASE_T)             //ʱС40Сʱ 
            salary += hour * BASE_D;
        else                         //ʱ40Сʱ, 40Сʱ + 40СʱֵĹ 
            salary += BASE_D * BASE_T + ((hour - BASE_T) * OVER_T) * BASE_D;
            
        if(salary <= TAX1)                        //ܹ300, Ӧ˰ 
            tax += salary * RATE1;
        else if(salary <= TAX2)                    //ܹ300~450֮, Ӧ˰ 
            tax += BASE_TAX1 + (salary - TAX1) * RATE2;
        else
            tax += BASE_TAX1 + BASE_TAX2 + (salary - TAX2) * RATE3;    //ܹʳ450, Ӧ˰ 
        
        printf("ܶ: %10.2f\n˰    : %10.2f\n  : %10.2f\n",
                salary, tax, salary - tax);
            
        while(getchar() != '\n')        //ջ 
                continue;
        menu();        //μ,´ӡ˵ 
    }
    printf("\nBye~");
    return 0;
}

void menu(void)
{
    printf("*****************************************************************\n");
    printf("Enter the number corresponding to the desired pay rate or action:\n");
    printf("1) $8.75/hr                     2) $9.33/hr\n");
    printf("3) $10.00/hr                    4) $11.20/hr\n");
    printf("5) quit\n");
    printf("*****************************************************************\n");
    printf("Please select(1 ~ 5): ");
}


[ Ryker 2013-5-3 17:44 ༭ ]
2013-05-03 17:37
m
Rank: 3Rank: 3
ȡ̳
ӣ48
רҷ֣145
ע᣺2013-4-1
ղ
÷:0 
ĿǰΪֹһûóʵ

һöظд󣬻½⣡
2013-05-03 17:54
¼ŵС
Rank: 2
ȡ̳
ӣ26
רҷ֣45
ע᣺2013-4-30
ղ
÷:0 
˼
2013-05-03 22:25
Ryker
Rank: 6Rank: 6
ȡ֮
1
ӣ145
רҷ֣420
ע᣺2013-2-19
ղ
÷:0 
ظ 3¥ ¼ŵС
Ŷ

ʱɡҪ»ˣ
2013-05-03 23:20
Han_FlyB
Rank: 6Rank: 6
ȡ֮
ӣ143
רҷ֣424
ע᣺2013-3-25
ղ
÷:0 
һϰ߰д
2013-05-04 12:30
Ryker
Rank: 6Rank: 6
ȡ֮
1
ӣ145
רҷ֣420
ע᣺2013-2-19
ղ
÷:0 
ظ 5¥ Han_FlyB
CPPѧ

ANSI C׼..
2013-05-04 13:11
lw749080910
Rank: 1
ȡ·
ӣ1
רҷ֣0
ע᣺2013-5-5
ղ
÷:0 
ۡܰ
2013-05-05 20:28
ʿ
Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19Rank: 19
ԣӺ
ȡ
61
ӣ2392
רҷ֣13384
ע᣺2013-3-3
ղ
÷:0 
н

Maybe
2013-05-05 20:35
ٻظĿǰΪֹдij...Ȼܼ...
ݼ...
 



| | й | Cookies | TOP | ֻ

й ȨУȨ
Powered by Discuz, Processed in 0.025580 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved