打印工资
已知基本工资率、加班费计算及税率,打印工资总额、税金及净工资
假设如下:
(1) 基本工资率=每小时应支付美元,例如10美元/小时
(2) 加班(每周超过40小时)=(基本工资率)*2.5
(3) 税率:
- 前300美元的15%;
- 下一笔150美元的20%;
- 剩下的25%
编写一个程序,首先显示一个支付率菜单,从中选择:
输入与所需付薪率或操作相对应的数字:
1) 8.75美元/小时
2)9.33美元/小时
3) 10.00美元/小时
4)11.20美元/小时
5) 退出
使用Scanf(“%d”,&choice)获取用户的选择,使用开关(choice)选择支付率。
(1) 如果选择了选项1到4,程序应请求工作小时数;
(2) 程序应循环使用,直到输入5;
(3) 如果输入的不是选项1到5,程序应该提醒用户正确的选择是什么,然后循环使用。
最后,程序应该打印工资总额、税金和净工资。
/*
Name:programme3.c
Author:祁麟
copyright:BJTU | school of software 2004
Date:2020/10/13
Description:prints the gross pay, the taxes, and the net pay.
*/
#include <stdio.h>
#define PayRate1 8.75
#define PayRate2 9.33
#define PayRate3 10.00
#define PayRate4 11.20
#define TaxRate1 0.15
#define TaxRate2 0.20
#define TaxRate3 0.25
int main (){
int choice,hour;
float GrossPay,tax,NetPay;
printf ("*****************************************************************\n");
printf ("Enter the number corresponding to the desired pay rate or action:\n");
printf ("1) $8.75/hr ");
printf ("2) $9.33/hr\n");
printf ("3) $10.00/hr ");
printf ("4) $11.20/hr\n");
printf ("5) quit\n");
printf ("*****************************************************************\n");
while (1){
scanf ("%d",&choice);
if (choice == 5) break;
switch (choice) {
case 1:
printf ("Please enter the hours worked:");
scanf ("%d",&hour);