某单位发放职工工资时,采用现金发放,需要根据职工工资总额计算出各种面值币额的数量,即根据键盘输入每个员工的工资总额,分别计算100圆币,50圆币,10圆币,5圆币,2圆币,1圆币的数量,编程实现其功能
时间: 2024-06-13 10:08:40 浏览: 4
以下是Python实现某单位发放职工工资时,计算各种面值币额数量的代码:
```python
n = int(input("请输入职工人数:"))
total_salary = 0
coins = [100, 50, 10, 5, 2, 1] # 各种面值币额
coin_counts = [0] * 6 # 初始化各种面值币额数量为0
for i in range(n):
salary = int(input("请输入第{}个职工的工资总额:".format(i+1)))
total_salary += salary
for j in range(6):
coin_counts[j] += salary // coins[j] # 计算各种面值币额数量
salary %= coins[j]
print("工资总额为:{}元".format(total_salary))
print("各种面值币额数量为:")
for i in range(6):
print("{}元:{}张".format(coins[i], coin_counts[i]))
```
相关问题
某单位发放职工工资时,采用现金发放,需要根据职工工资总额计算出各种面额人民币的张数,即根据键盘输入每个员工的工资总额,分别计算面额为100元,50元,10元,5元,1元的张数,编程实现其功能
以下是Python实现某单位发放职工工资时,计算各种面额人民币张数的代码:
```python
n = int(input("请输入职工人数:"))
total_salary = 0
for i in range(n):
salary = int(input("请输入第{}个职工的工资总额:".format(i+1)))
total_salary += salary
print("职工工资总额为:{}元".format(total_salary))
# 计算各种面额人民币的张数
money_list = [100, 50, 10, 5, 1]
for money in money_list:
num = total_salary // money
total_salary = total_salary % money
print("{}元的张数为:{}".format(money, num))
```
运行代码后,首先输入职工人数,然后依次输入每个职工的工资总额,程序会计算出职工工资总额,并根据面额为100元、50元、10元、5元、1元的纸币计算出各自的张数。
输入n(n<=50)个职工的工资(单位为元,一元以下部分舍去),计算工资总额,计算给职工发放工资时,所需各种面额人民币的最小张数(分壹佰元,伍拾元,贰拾元,拾元,伍元,壹元六种)C语言
以下是一个示例代码,可以实现输入n个职工的工资,计算工资总额,并计算给职工发放工资时,所需各种面额人民币的最小张数:
```c
#include <stdio.h>
int main() {
int n, i, salary, totalSalary = 0;
int num[6] = {0}; // 分别表示100元、50元、20元、10元、5元、1元的张数
printf("请输入职工人数:");
scanf("%d", &n);
for (i = 0; i < n; i++) {
printf("请输入第%d个职工的工资:", i+1);
scanf("%d", &salary);
totalSalary += salary;
// 计算各种面额人民币的张数
num[0] += salary / 100;
salary %= 100;
num[1] += salary / 50;
salary %= 50;
num[2] += salary / 20;
salary %= 20;
num[3] += salary / 10;
salary %= 10;
num[4] += salary / 5;
salary %= 5;
num[5] += salary;
}
printf("工资总额为:%d元\n", totalSalary);
printf("需要各种面额人民币的最小张数为:\n");
printf("100元:%d张\n", num[0]);
printf("50元:%d张\n", num[1]);
printf("20元:%d张\n", num[2]);
printf("10元:%d张\n", num[3]);
printf("5元:%d张\n", num[4]);
printf("1元:%d张\n", num[5]);
return 0;
}
```
该程序首先要求用户输入职工人数,然后通过循环,逐个输入每个职工的工资。在输入工资时,程序将工资累加到总工资中,并且计算出各种面额人民币的最小张数。最后,程序输出工资总额和各种面额人民币的最小张数。
相关推荐
![application/x-rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![txt](https://img-home.csdnimg.cn/images/20210720083642.png)
![txt](https://img-home.csdnimg.cn/images/20210720083642.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)