7.12.8

1608836-20190428225702131-224409008.png

 #  7.12.8
#include <stdio.h>
#define over_time  1.5 * 10
#define three_hundred_rate  0.15
#define one_hundred_half_rate  0.2
#define more_then_four_hun_half_rate  0.25
#define three_hundred  45
#define four_hundred_half  75
float rate(float n);
int main(void)
{
    float hours;
    float wage;
    float basic_wage = 0;
    int grade;
    printf("grade is %d\n", grade);
    
   
   
    part: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");
        
        if (scanf("%d", &grade) == 1 && (grade > 0)  && (grade < 6))
        {
            switch (grade)
            {
                case 1:
                          basic_wage = 8.75;
                          break;
                case 2:
                          basic_wage = 9.33;
                          break;
                case 3:
                          basic_wage = 10.00;
                          break;
                case 4:
                          basic_wage = 11.20;
                          break;
                case 5:
                          goto quit;
            }
            
//            printf("basic_wage is %f\n", basic_wage);
            printf("请输入工作时长:");
            scanf("%f", &hours);
            if (( hours <= (float)40) && (hours >= 0))
                wage = basic_wage * hours;
            else 
                wage = basic_wage * 40 + (hours - (float)40) * over_time;
            printf("工资总额:%.2f,税金:%.2f,净收入:%.2f\n",
                    wage, rate(wage), wage - rate(wage));
            
            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");
             scanf("%d", &grade);

        }
        
             printf("请输入正确选项!\n");
             goto part;
    

    quit: printf("再见!\n");
    return 0;
}

float rate(float n)    // 函数定义
{
    float tax;
    if (n <= 300)
        tax = three_hundred_rate * n;
    else if (n <= 450)
        tax = three_hundred + (n - (float)300) * one_hundred_half_rate;
    else 
        tax = four_hundred_half + (n - (float)450) * more_then_four_hun_half_rate; 

    return tax;    // 返回tax的值
}

1608836-20190428225830121-1765502796.png

转载于:https://www.cnblogs.com/EisNULL/p/10787594.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值