还不够好 发表于 2020-10-11 11:52:15

做一个工资表输出,不太会

(金融应用程序:工资表)编写一个程序,读取下面的信息,然后打印一个工资表。

输入格式:


雇员姓名
一周工作时间
每小时报酬
预扣税率
养老金

输出格式:

输出每一项具体内容,如下输出样例所示
在这里给出一组输入。例如:


Smith
10
7.5
0.2
0.09


输出样例:

在这里给出相应的输出。例如


Employee Name: Smith

Hours Worked:10
Pay Rate: $7.5
Gross Pay: $75.0
Deductions:
Withholding (20.0%): $15.0
Pension (9.0%):$6.75
Total Deduction:$21.75
Net Pay:   $53.25

谢谢各位大佬,在线等,

疾风怪盗 发表于 2020-10-11 12:13:58

https://mp.weixin.qq.com/s/_esyb58rRvx0YaqinjGBSQ

你是想要这样的工资单吧?

昨非 发表于 2020-10-11 12:15:39

本帖最后由 昨非 于 2020-10-11 13:51 编辑

name = input("请输入雇员姓名:")
working_time = float(input("请输入一周工作时间:"))
Pay_Rate = float(input("请输入每小时报酬:"))

deductions= float(input("请输入预扣税率:"))
Pension = float(input("请输入养老金:"))

a = working_time*Pay_Rate*deductions
b = working_time*Pay_Rate*Pension

print("Hours Worked:",working_time)
print("Pay Rate: $",Pay_Rate)
print("Gross_Pay:$",working_time*Pay_Rate)
print("Deductions:")
print("Withholding (",deductions*100,"%): $",a)
print("Pension (",Pension*100,"%): $",b)
print("Total Deduction:$",a+b)
print("Net Pay:$",working_time*Pay_Rate*(1-(Pension+deductions)))

昨非 发表于 2020-10-11 12:16:22

敲一遍挺不容易的,给个最佳吧{:10_277:}

还不够好 发表于 2020-10-11 13:31:57

昨非 发表于 2020-10-11 12:16
敲一遍挺不容易的,给个最佳吧

是学校出的题,还是不对

昨非 发表于 2020-10-11 13:34:34

还不够好 发表于 2020-10-11 13:31
是学校出的题,还是不对

我这里运行没问题啊?哪里不对?

还不够好 发表于 2020-10-11 13:37:13

https://imgchr.com/i/0ctiJs

还不够好 发表于 2020-10-11 13:37:52

昨非 发表于 2020-10-11 13:34
我这里运行没问题啊?哪里不对?

https://imgchr.com/i/0ctiJs

昨非 发表于 2020-10-11 13:41:46

还不够好 发表于 2020-10-11 13:37


图片加载不出来

liuzhengyuan 发表于 2020-10-11 13:43:35

昨非 发表于 2020-10-11 13:41
图片加载不出来

https://imgchr.com/i/0ctiJs
你没有严格按照输入输出格式

liuzhengyuan 发表于 2020-10-11 13:46:41

你就直接把 3 楼的代码原封不动的复制进去?{:10_277:}

昨非 发表于 2020-10-11 13:52:05

还不够好 发表于 2020-10-11 13:37


请楼主按题目要求做出必要修改,三楼代码没问题

疾风怪盗 发表于 2020-10-11 13:58:48

还以为是工作中用到的{:10_284:}原来还是学生党。。。。。。
三楼代码没问题,稍作下修改,Total Deduction按照题目应该是显示两位小数
name = 'Smith'# input("请输入雇员姓名:")
working_time = 10# float(input("请输入一周工作时间:"))
Pay_Rate = 7.5# float(input("请输入每小时报酬:"))

deductions = 0.2# float(input("请输入预扣税率:"))
Pension = 0.09# float(input("请输入养老金:"))

print("Hours Worked:", working_time)
print("Pay Rate: $", Pay_Rate)
print("Gross_Pay:$", working_time * Pay_Rate)
print("Deductions:")
print("\tWithholding (", deductions * 100, "%): $", working_time * Pay_Rate * deductions)
print("\tPension (", Pension * 100, "%): $", working_time * Pay_Rate * Pension)
print("\tTotal Deduction:${:.2f}".format (working_time * Pay_Rate * (Pension + deductions)))
print("Net Pay:$", working_time * Pay_Rate * (1 - (Pension + deductions)))


Hours Worked: 10
Pay Rate: $ 7.5
Gross_Pay:$ 75.0
Deductions:
        Withholding ( 20.0 %): $ 15.0
        Pension ( 9.0 %): $ 6.75
        Total Deduction:$21.75
Net Pay:$ 53.25

昨非 发表于 2020-10-11 15:49:52

疾风怪盗 发表于 2020-10-11 13:58
还以为是工作中用到的原来还是学生党。。。。。。
三楼代码没问题,稍作下修改,Total Deductio ...

学生党怎么了嘛{:10_266:}

疾风怪盗 发表于 2020-10-11 16:04:18

昨非 发表于 2020-10-11 15:49
学生党怎么了嘛

{:10_256:}羡慕啊。。。。。。。。

昨非 发表于 2020-10-11 16:08:01

疾风怪盗 发表于 2020-10-11 16:04
羡慕啊。。。。。。。。

{:10_266:}除了年轻,别无优势{:10_256:}
页: [1]
查看完整版本: 做一个工资表输出,不太会