public class Method_Exer07 { class AvgWag{ String[][] employeeS = { {"10", "1", "段誉", "22", "3000"}, {"13", "2", "令狐冲", "32", "18000", "15000", "2000"}, {"11", "3", "任我行", "23", "7000"}, {"11", "4", "张三丰", "24", "7300"}, {"12", "5", "周芷若", "28", "10000", "5000"}, {"11", "6", "赵敏", "22", "6800"}, {"12", "7", "张无忌", "29", "10800", "5200"}, {"13", "8", "韦小宝", "30", "19800", "15000", "2500"}, {"12", "9", "杨过", "26", "9800", "5500"}, {"11", "10", "小龙女", "21", "6600"}, {"11", "11", "郭靖", "25", "7100"}, {"12", "12", "黄蓉", "27", "9600", "4800"} }; int avgwages; int sumwages; int avgage; public void Avgage(int a,int b){ //平均年龄 a:总年龄 b:人数 avgage=a/b; } public void AvgWages(int a,int b){//平均工资 a:总工资 b:人数 avgwages=a/b; } public void SumIncome(int a){ sumwages+=a; } } public class Method_Exer7 { public void main(String[] args) { AvgWag wag=new AvgWag(); wag.Avgage(22,1); System.out.println("普通员工的平均年龄为:" +wag.avgage+"岁"); wag.Avgage(23+24+22+21+25,5); System.out.println("程序员的平均年龄为:"+wag.avgage+"岁"); wag.Avgage(28+29+26+27,4); System.out.println("设计师的平均年龄为:"+wag.avgage+"岁"); wag.Avgage(32+30,2); System.out.println("架构师的平均年龄为:"+wag.avgage+"岁"); wag.AvgWages(3000,1); System.out.println("普通员工的平均工资为"+wag.avgwages+"元"); wag.AvgWages(7000+7300+6800+6600+7100,5); System.out.println("程序员的平均工资为"+wag.avgwages+"元"); wag.AvgWages(10000+10800+9800+9600,4); System.out.println("设计师的平均工资为"+wag.avgwages+"元"); wag.AvgWages(19800+18000,2); System.out.println("架构师的平均工资为:"+wag.avgwages+"元"); wag.SumIncome(3000); System.out.println("普通员工的总收入为:"+wag.sumwages+"元"); wag.SumIncome(7000+7300+6800+6600+7100); System.out.println("程序员的总收入为:"+wag.sumwages+"元"); wag.SumIncome(10000+10800+9800+9600+5000+5200+5500+4800); System.out.println("设计师的总收入为:"+wag.sumwages+"元"); wag.SumIncome(19800+18000+15000+2000+15000+2500); System.out.println("架构师的总收入为:"+wag.sumwages+"元"); } } }