C语言入门 -- 打印工资总额、税金及净工资(2020/12/11)

打印工资

已知基本工资率、加班费计算及税率,打印工资总额、税金及净工资

假设如下:
(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);
  • 5
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

RowdyKid

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值