当前位置: 编程技术>java/j2ee
java利用数组求平均值,最大值,最小值
来源: 互联网 发布时间:2014-10-29
本文导语: 代码如下:(测试类) package com.badu; public class Tste { public static void main(String[] args) { Class5 sa=new Class5("周阿郎",3,2,24); Class5 [] a=new Class5[5]; a[0]=new Class5("张扬",2,4,34); ...
代码如下:
(测试类)
package com.badu;
public class Tste {
public static void main(String[] args) {
Class5 sa=new Class5("周阿郎",3,2,24);
Class5 [] a=new Class5[5];
a[0]=new Class5("张扬",2,4,34);
a [1]=new Class5("刘禅",3,2,24);
a[2]=new Class5("张燕",4,23,78);
a [3]=new Class5("周少博",32,23,99);
a [4]=new Class5("张旭",24,13,100);
System.out.println(sa.toString());
double [] w={a[0].getSJava(),a[1].getSJava(),a[2].getSJava(),a[3].getSJava(),a[4].getSJava()};
int s=0;
double max=w[2];
double min=w[0];
for(int i=0;i