java发工资_Java发工资

作为企业的老板,最盼望的日子就是每月的8号了,因为这一天是发工资的日子,养家糊口就靠它了,呵呵

但是对于财务处的工作人员来说,这一天则是很忙碌的一天,财务处的小胡最近就在考虑一个问题:

如果每个员工的工资额都知道,最少需要准备多少张人民币,才能在给每位员工发工资的时候都不用找零呢?

这里假设员工的工资都是正整数,单位元,人民币一共有100元、50元、10元、5元、2元和1元六种。

Input

输入数据包含多个测试实例,每个测试实例的第一行是一个整数n(n<100),表示员工的人数,然后是n个员工的工资。

n=0表示输入的结束,不做处理。

Output

对于每个测试实例输出一个整数x,表示至少需要准备的人民币张数。每个输出占一行。

Sample Input

3

1 2 3

0

Sample Output

4

public class FaGongZi {

public static void main(String[] args) {

String str="1 2 3 1578";

System.out.println(method(str));

}

public static int method(String str){

String[] strs=str.split(" ");

int count=0;

for(String s:strs){

count+=method2(Integer.parseInt(s));

}

return count;

}

public static int method2(int sal){

int count=0;

if(sal>=100){

while(sal>=100){

sal-=100;

count++;

}

}

if(sal>=50){

while(sal>=50){

sal-=50;

count++;

}

}

if(sal>=10){

while(sal>=10){

sal-=10;

count++;

}

}

if(sal>=5){

while(sal>=5){

sal-=5;

count++;

}

}

if(sal>=2){

while(sal>=2){

sal-=2;

count++;

}

}

if(sal>=1){

while(sal>=1){

sal-=1;

count++;

}

}

return count;

}

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值