Java uses arrays for average, maximum, minimum _java

Source: Internet
Author: User
Copy Code code as follows:

(Test Class)

Package Com.badu;

public class Tste {




public static void Main (string[] args) {
CLASS5 sa=new Class5 ("Zhou Along", 3,2,24);
CLASS5 [] a=new class5[5];
A[0]=new CLASS5 ("publicity", 2,4,34);
A [1]=new Class5 ("Liu Chan", 3,2,24);
A[2]=new Class5 ("Zhang Yan", 4,23,78);
A [3]=new Class5 ("Zhou Shaobo", 32,23,99);
A [4]=new Class5 ("Zhangxuyue", 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<5;i++) {
S+=W[I]/5;
if (Max<w[0]) {
MAX=W[2];
}
if (Min>w[0]) {
MIN=W[0];

}

}
System.out.println ("The average of Java scores is" +s+ ", the minimum value is" +min+ ", the maximum is" +max ");
}

}
(i)

Package Com.badu;

public class Class5 {
private String name;
private int age;
private int sno;
private int Sjava;
Public Class5 (String a,int w,int g,int l) {

Name=a;
Age=w;
sno=g;
Sjava=l;

}public Class5 (int b) {
Age=b;
}public Class5 (int c,int d) {

Sno=c;
Sjava=d;


}
Public Class5 () {}
Public String GetName () {
return name;

}
public int getage () {
return age;
}
public int Getno () {
Return SNO;
}
public int Getsjava () {
return Sjava;
}
Public String toString () {
String s= "I am called" +name+ ", I this year" +age+ "+" My Java grade is "+sjava;
return s;
}
public static void Main (string[] args) {


}

}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.