定义一个接口,接口中有三个抽象方法:1.long fact(int m);方法的功能为求参数的阶乘。2.long intPower(in

定义一个接口,接口中有三个抽象方法:1.long fact(int m);方法的功能为求参数的阶乘。2.long intPower(int m,int n);方法的功能为求参数m的n次方。3.boolean findFactor(int m,int n);方法的功能为判断参数中较小数是否为较大数的因子。定义类实现该接口。编写应用程序,调用接口中三个方法,并将调用方法所得的结果输出。
快点吧,谢了。

public interface F {
public long fact(int m);

public long intPower(int m,int n);

public boolean findFactor(int m,int n);
}

public class Face implements F{
public int Fm = 1;
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Face f=new Face();
System.out.println("M的阶乘为:"+f.fact(8));
System.out.println("m的n次方为:"+f.intPower(8, 4));
System.out.println("参数中较小数是否是较大数的因子:"+f.findFactor(4, 8));
}
public long fact(int m){
for(int i=1;i<=m;i++){
Fm*=i;
}
return Fm;
}

public long intPower(int m,int n)
{
if(n==1)
return m;

else
return intPower(m,n-1)*m;
}

public boolean findFactor(int m,int n){
return m>=n? m%n==0?true:false:n%m==0?true:false;
}
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2010-11-10
据该i偶然间饿哦过
相似回答