| ÍøÕ¾Ê×Ò³ | Òµ½çÐÂÎÅ | С×é | Íþ¿Í | È˲Š| ÏÂÔØƵµÀ | ²©¿Í | ´úÂëÌù | ÔÚÏß±à³Ì | ±à³ÌÂÛ̳
»¶Ó­¼ÓÈëÎÒÃÇ£¬Ò»Í¬Çд輼Êõ
Óû§Ãû£º   
 
ÃÜ¡¡Â룺  
¹²ÓÐ 863 È˹Ø×¢¹ý±¾Ìû
±êÌ⣺ĿǰΪֹдµÄ×µÄ³ÌÐòÁË...ËäÈ»ºÜ¼òµ¥...
È¡ÏûÖ»¿´Â¥Ö÷ ¼ÓÈëÊÕ²Ø
Ryker
Rank: 6Rank: 6
µÈ¡¡¼¶£ºÏÀÖ®´óÕß
Íþ¡¡Íû£º1
Ìû¡¡×Ó£º145
ר¼Ò·Ö£º420
×¢¡¡²á£º2013-2-19
½áÌûÂÊ£º100%
ÊÕ²Ø
 ÎÊÌâµãÊý£º0 »Ø¸´´ÎÊý£º2 
ĿǰΪֹдµÄ×µÄ³ÌÐòÁË...ËäÈ»ºÜ¼òµ¥...
³ÌÐò´úÂ룺
/* ±àд³ÌÐò, ÒªÇóÊäÈëÒ»ÖÜÖеŤ×÷СʱÊý,È»ºó´òÓ¡¹¤×Ê×ܶî,Ë°½ðÒÔ¼°¾»¹¤×Ê

 * ×÷ÈçϼÙÉè:

 * 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 ±à¼­ ]
ËÑË÷¸ü¶àÏà¹ØÖ÷ÌâµÄÌû×Ó: ¹¤×Ê¡¡±àд³ÌÐò¡¡color¡¡
2013-05-03 17:37
Ryker
Rank: 6Rank: 6
µÈ¡¡¼¶£ºÏÀÖ®´óÕß
Íþ¡¡Íû£º1
Ìû¡¡×Ó£º145
ר¼Ò·Ö£º420
×¢¡¡²á£º2013-2-19
ÊÕ²Ø
µÃ·Ö:0 
»Ø¸´ 3Â¥ ¹Â¼ÅµÄС²Ë
Ŷ¡£¡£

µ±Ê±ÔÚÍø°É¡£ÒªÏ»úÁË£¬¾ÍÌûÔÚÕâÀï¡£¡£
2013-05-03 23:20
Ryker
Rank: 6Rank: 6
µÈ¡¡¼¶£ºÏÀÖ®´óÕß
Íþ¡¡Íû£º1
Ìû¡¡×Ó£º145
ר¼Ò·Ö£º420
×¢¡¡²á£º2013-2-19
ÊÕ²Ø
µÃ·Ö:0 
»Ø¸´ 5Â¥ Han_FlyB
ÎÒÕÕ×ÅCPPѧµÄ

ANSI C±ê×¼..
2013-05-04 13:11
¿ìËٻظ´£ºÄ¿Ç°ÎªÖ¹Ð´µÄ×µÄ³ÌÐòÁË...ËäÈ»ºÜ¼òµ¥...
Êý¾Ý¼ÓÔØÖÐ...
 
¡¡¡¡¡¡



¹ØÓÚÎÒÃÇ | ¹ã¸æºÏ×÷ | ±à³ÌÖйú | Çå³ýCookies | TOP | ÊÖ»ú°æ

±à³ÌÖйú °æȨËùÓУ¬²¢±£ÁôËùÓÐȨÀû¡£
Powered by Discuz, Processed in 0.025401 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved