繁体   English   中英

我需要在我的代码末尾打印一个计算好的奖金,但我似乎不知道怎么做。 我将如何 go 关于这个?

[英]I need to make a calculated bonus print out at the end of my code but I can not seem to figure out how. How would I go about this?

比如我输入10000,那么输入数字1。output就是10125.0。 我需要能够像这样打印:

The raise is: 125
Salary is now: 10125.0
current_sal = int(input("Please enter your current salary: "))
employee_rank = -1
int(employee_rank)
while int(employee_rank) <0 or int(employee_rank) >5:
employee_rank = input("Please enter your employee rank: ")
sal_plus_raise = 0
if employee_rank == '5':
sal_plus_raise = current_sal + (.035 * current_sal)
elif employee_rank == '4':
sal_plus_raise = current_sal + (.0325 * current_sal)
elif employee_rank == '3':
sal_plus_raise = current_sal + (.025 * current_sal)
elif employee_rank == '2':
sal_plus_raise = current_sal + (.02 * current_sal)
elif employee_rank == '1':
sal_plus_raise = current_sal + (.0125 * current_sal)
else:
sal_plus_raise = current_sal

print ("Salary is: ",sal_plus_raise)

根据您的需要,计算salary_raise并使用它来返回total_salaryraise本身是有意义的。

您的代码的修改版本只是进行了更改,并删除了一些我认为您不需要的东西(根据给出的描述):

current_sal = int(input("Please enter your current salary: "))
employee_rank = input("Please enter your employee rank: ")
salary_raise = 0
if employee_rank == '5':
    salary_raise = .035 * current_sal
elif employee_rank == '4':
    salary_raise = .0325 * current_sal
elif employee_rank == '3':
    salary_raise = .025 * current_sal
elif employee_rank == '2':
    salary_raise = .02 * current_sal
elif employee_rank == '1':
    salary_raise = .0125 * current_sal

print("The raise is: ", salary_raise)
print("Salary is now: ", current_sal + salary_raise)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM