public class Test {
private int sum = 0;
private int count = 0;
public void print(){
int n = 100/5;
// 由于能被5整除的只能是5的倍数这里用求5的倍数的方法来求解
System.out.println("能被5整除的是: ");
for(int i = n;i*5<=200;i++){
System.out.print(i*5+" ");
sum += i*5;
count++;
}
System.out.println();
System.out.println("平均值是 "+ sum/count);
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Test t = new Test();
t.print();
}
}
public class Devide {
private int i;
private int k=0;
private int sum=0;
public void f() {
System.out.print("能被5整除的数是:");
for(i=100;i<=200;i++){
if(i%5 == 0){
System.out.print(i+" ");
sum += i;
k++;}
}
System.out.println();
System.out.println("平均数是:"+sum/k);
}
public static void main(String[] args) {
Devide a = new Devide();
a.f();
}
}