代码编织梦想

public class task02 {


    public static void main(String[] args) {

        //创建employee类的对象
        Employee staff = new Employee();

        Employee prog = new Employee();

        Employee desi = new Employee();

        Employee arch = new Employee();

        String[][] employees = {
                {"10", "1", "段誉", "22", "3000","0","0"},
                {"13", "2", "令狐冲", "32", "18000", "15000", "2000"},
                {"11", "3", "任我行", "23", "7000","0","0"},
                {"11", "4", "张三丰", "24", "7300","0","0"},
                {"12", "5", "周芷若", "28", "10000", "5000","0"},
                {"11", "6", "赵敏", "22", "6800","0","0"},
                {"12", "7", "张无忌", "29", "10800", "5200","0"},
                {"13", "8", "韦小宝", "30", "19800", "15000", "2500"},
                {"12", "9", "杨过", "26", "9800", "5500","0"},
                {"11", "10", "小龙女", "21", "6600","0","0"},
                {"11", "11", "郭靖", "25", "7100","0","0"},
                {"12", "12", "黄蓉", "27", "9600", "4800","0"}
        };
//        创建新的数组
        int salary[] = new int[employees.length];
        int age[] = new int[employees.length];
        int bonus[] = new int[employees.length];
        int shares[] = new int[employees.length];
//        用新的数组将string转换为int值
        for (int i = 0; i < employees.length; i++) {
            age[i] = Integer.parseInt(employees[i][3]);
            salary[i] = Integer.parseInt(employees[i][4]);
            bonus[i] = Integer.parseInt(employees[i][5]);
            shares[i] = Integer.parseInt(employees[i][6]);
        }
        for (int i = 0; i < employees.length; i++) {
            switch (employees[i][0]) {
                case "10":
                    staff.count ++;
                    staff.wageSum += salary[i];
                    staff.ageSum += age[i];
                    staff.bonusSum += bonus[i];
                    staff.sharesSum += shares[i];
                    break;
                case "11":
                    prog.count ++;
                    prog.wageSum += salary[i];
                    prog.ageSum += age[i];
                    prog.bonusSum += bonus[i];
                    prog.sharesSum += shares[i];
                    break;
                case "12":
                    desi.count ++;
                    desi.wageSum += salary[i];
                    desi.ageSum += age[i];
                    desi.bonusSum += bonus[i];
                    desi.sharesSum += shares[i];
                    break;
                case "13":
                    arch.count ++;
                    arch.wageSum += salary[i];
                    arch.ageSum += age[i];
                    arch.bonusSum += bonus[i];
                    arch.sharesSum += shares[i];
                    break;
            }
        }
        System.out.println("员工类型\t\t数量\t平均年龄\t\t平均薪资\t\t总收入");

        int staffAvgWages = staff.getAvgWages(staff.wageSum, staff.count);
        int staffAvgAge = staff.getAvgAge(staff.ageSum, staff.count);
        int staffIncomSum = staff.getIncomSum(staff.wageSum, staff.bonusSum, staff.sharesSum);
        System.out.println("普通员工" + "\t\t" + staff.count + "\t\t" + staffAvgAge + "\t\t\t" + staffAvgWages + "\t\t" + staffIncomSum );

        int progAvgWages = prog.getAvgWages(prog.wageSum, prog.count);
        int progAvgAge = prog.getAvgAge(prog.ageSum, prog.count);
        int progIncomSum = prog.getIncomSum(prog.wageSum, prog.bonusSum, prog.sharesSum);
        System.out.println("程序员" + "\t\t" + prog.count + "\t\t" + progAvgAge + "\t\t\t" + progAvgWages + "\t\t" + progIncomSum );

        int desiAvgWages = desi.getAvgWages(desi.wageSum, desi.count);
        int desiAvgAge = desi.getAvgAge(desi.ageSum, desi.count);
        int desiIncomSum = desi.getIncomSum(desi.wageSum, desi.bonusSum, desi.sharesSum);
        System.out.println("设计师" + "\t\t" + desi.count + "\t\t" + desiAvgAge + "\t\t\t" + desiAvgWages + "\t\t" + desiIncomSum );

        int archAvgWages = arch.getAvgWages(arch.wageSum, arch.count);
        int archAvgAge = arch.getAvgAge(arch.ageSum, arch.count);
        int archIncomSum = arch.getIncomSum(arch.wageSum, arch.bonusSum, arch.sharesSum);
        System.out.println("架构师" + "\t\t" + arch.count + "\t\t" + archAvgAge + "\t\t\t" + archAvgWages + "\t\t" + archIncomSum );
    }

    //      员工类
    static class Employee {
        int count = 0;
        int wageSum = 0;
        int ageSum = 0;
        int bonusSum = 0;
        int sharesSum = 0;
        //          求平均工资方法
        public int getAvgWages(int wageSum, int employeeSum) {
            int avgwages = wageSum / employeeSum;
            return avgwages;
        }

        //          求平均年龄方法
        public int getAvgAge(int ageSum, int employeeSum) {
            int avgAge = ageSum / employeeSum;
            return  avgAge;
        }

        //             求总收入方法
        public int getIncomSum(int wageSum, int bonusSum, int sharesSum) {
            int incomSum = wageSum + bonusSum + sharesSum;
            return  incomSum;
        }
    }
}
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/qq_69924807/article/details/127002595

k-means聚类中国城市_lilong117194的博客-爱代码爱编程

聚类是一种学习方法,即把物理或抽象对象的集合分组为由彼此类似的对象组成的多个类的分析过程。 K-Means是基于向量距离来做聚类的 算法步骤: 从n个向量对象任意选择k个向量作为初始聚类中心根据步骤1中的设置的k个向量

香橙派全志H3烧入U-boot和Linux内核以及配置-爱代码爱编程

全志H3烧入U-boot和Linux内核以及配置 1.U-boot的烧入和U-boot环境配置1.1U-boot烧入和启动测试2.编译完的内核处理和烧入2.1处理内核2.2烧入内核U-boot环境配置 1.U-boot的烧入和U-boot环境配置 1.1U-boot烧入和启动测试 需要的材料: 准备一张性能良好的TF卡,不要用淘宝那种几块钱

一、【vue-router】路由基本使用_纯纯的小白的博客-爱代码爱编程

一、路由基本使用 Vue Router 就是 Vue 的一个插件库,专门用来实现 SPA 应用。 SPA: 单页面 Web 应用( single page web application, SPA )整个应用