public interface A {

    public abstract long fact(int m);
    public abstract long intPower(int m,int n);
    public abstract boolean findFactor(int m,int n);
    
}public class B implements <A>{//18行

int m;
int n;
public  long fact(int m){
this.m = m;
int i;
double x = 1;
for(i = 1;i <= m;i++){
x *= i;
System.out.println(m+"的阶乘是:"+x);
}
}
    public  long intPower(int m,int n){
     this.m = m;
     this.n = n;
     double y;
     if(n > 0){
     y = m*intPower(int m, int n-1);//36行
     }
        System.out.println(m+"的n次方是:"+y);
    }
    public  boolean findFactor(int m,int n){
    
     this.m = m;
     this.n = n;
     if(m <= n && n%m==0){
     System.out.println("m是n的因子");
     }
     if(n <= m && m%n ==0){
     System.out.println("n是m的因子");
     }
    }
    
    public B(int m,int n){
    
     this.m = m;
     this.n = n;
    }
    
    public static void main (String[] args) {

B b = new B(2,4);
b.fact(2);
}
}
错误: 非法的类型开始 18行
错误: 非法的表达式开始 18行
错误: 需要 '.class' 36行
错误: 需要';' 36行
错误: 需要';' 36行

解决方案 »

  1.   

    public class B implements A{//18行y = m*intPower(m,  n-1);//36行//这里是 执行方法,又不是定义,怎么能有int?
      

  2.   

    改了4,5个错误。
    1.有返回类型却无返回值
    2.概念模糊,逻辑也没有描述清楚。interface A { public abstract long fact(int m); public abstract long intPower(int m, int n); public abstract boolean findFactor(int m, int n);
    }public class B implements A {//implement <A>是什么意思? int m;
    int n; public long fact(int m) {//阶乘
    this.m = m;
    int i;
    long x = 1;
    for (i = 1; i <= m; i++) {
    x *= i;
    }
    System.out.println(m + "的阶乘是:" + x);//放外面
    return x;
    } public long intPower(int m, int n) {
    this.m = m;
    this.n = n;
    long y = 0;
    if(n==0){//结束条件
    y = 1;
    }
    else if (n > 0){
    y = m * intPower(m, n - 1);//调用方法,递归
    }
    System.out.println(m + "的"+n+"次方是:" + y);
    return y;
    } public boolean findFactor(int m, int n) {//感觉逻辑有些问题。
    boolean flag = false;
    this.m = m;
    this.n = n;
    if (m <= n && n % m == 0) {
    System.out.println("m是n的因子");
    flag = true;
    }
    if (n < m && m % n == 0) {
    System.out.println("n是m的因子");
    flag= true;
    }
    return flag;
    } public B(int m, int n) {
    this.m = m;
    this.n = n;
    } public static void main(String[] args) {
    B b = new B(2, 4);
    b.fact(2);
    b.intPower(2,4);
    }
    }
      

  3.   

    interface A
    {
    /**
     * 是接口,为什么还用静态方法呢?
     * @param m
     * @return
     */ public  long fact(int m); public  long intPower(int m, int n); public  boolean findFactor(int m, int n);}public class B implements A
    { int m;
    int n; public long fact(int m)
    {
    this.m = m;
    int i;
    long x = 1;
    for (i = 1; i <= m; i++)
    {
    x *= i;

    }
    System.out.println(m + "的阶乘是:" + x);
    return x;
    } public long intPower(int m,int n){
      this.m = m;
      this.n = n;
      long y;
      if(n==1){        //递归终止的判断
      return m;
      }
      else{
         y = m*intPower( m,  n-1);//这里传的是实参
      }
      System.out.println(m+"的"+n+"次方是:"+y);
      return y;
       } public boolean findFactor(int m, int n)//定义的方法是返回一个布尔值的
    {
    this.m = m;
    this.n = n;
    if (m <= n && n % m == 0)
    {
    System.out.println(m+"是"+n+"的因子");

    }
    else if (n <= m && m % n == 0)
    {
    System.out.println(n+"是"+m+"的因子");

    }
    return true;
    } public B(int m, int n)
    { this.m = m;
    this.n = n;
    } public static void main(String[] args)
    { B b = new B(2, 4);
    b.intPower(5, 2);
    b.findFactor(100, 2);
    b.fact(5);
    }
    }
    你这程序太乱了。
      

  4.   

    interface A
    {
    /**
     * 是接口,为什么还用静态方法呢?
     * @param m
     * @return
     */ public  long fact(int m); public  long intPower(int m, int n); public  boolean findFactor(int m, int n);}public class B implements A
    { int m;
    int n; public long fact(int m)
    {
    this.m = m;
    int i;
    long x = 1;
    for (i = 1; i <= m; i++)
    {
    x *= i;

    }
    System.out.println(m + "的阶乘是:" + x);
    return x;
    } public long intPower(int m,int n){
      this.m = m;
      this.n = n;
      long y;
      if(n==1){        //递归终止的判断
      return m;
      }
      else{
         y = m*intPower( m,  n-1);//这里传的是实参
      }
      System.out.println(m+"的"+n+"次方是:"+y);
      return y;
       } public boolean findFactor(int m, int n)//定义的方法是返回一个布尔值的
    {
    this.m = m;
    this.n = n;
    if (m <= n && n % m == 0)
    {
    System.out.println(m+"是"+n+"的因子");

    }
    else if (n <= m && m % n == 0)
    {
    System.out.println(n+"是"+m+"的因子");

    }
    return true;
    } public B(int m, int n)
    { this.m = m;
    this.n = n;
    } public static void main(String[] args)
    {
    B b = new B(2, 4);
    b.intPower(5, 2);
    b.findFactor(100, 2);
    b.fact(5);
    }
    }