import java.util.Scanner;
public class koujue
{
public static void main(String [] args)
{
                  System.out.print("请输入一个整数:");//提示错误需要';'
Scanner sc=new Scanner(System.in);
int a=sc.nextInt();
Tools t=new Tools();
System.out.println(t.chengfa(a));
}
}
class Tools
{
public int chengfa(int x)
{
for(int i=1;i<=x;i++)
{
for(int j=1;j<=i;j++)
{
return j+"*"+i+"="+j*i+"\t";
}
}
}
}

解决方案 »

  1.   

    你的程序错的严重,是打印乘法口诀吧?我给你给了下:import java.util.Scanner;public class KouJue
    {
    public static void main(String[] args)
    {
    System.out.print("请输入一个整数:");
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    Tools t = new Tools();
    t.chengfa(a);
    }
    }class Tools
    {
    public void chengfa(int x)
    {
    for (int i = 1; i <= x; i++)
    {
    for (int j = 1; j <= i; j++)
    {
    System.out.print(j + "*" + i + "=" + j * i + "\t");
    }
    System.out.println();
    }
    }
    }
      

  2.   

    将tools的chengfa方法返回值,改为String
      

  3.   

     System.out.print("请输入一个整数:");//提示错误需要';'
    将前后的空格删除,重新添加试一试
      

  4.   

    首先分析一下楼主出错的原因:System.out.println(t.chengfa(a)); // 此句就打印一值,与楼主所需求的乘法口诀不符合
    return j + "*" + i + "=" + j * i + "\t"; // 些句返回的类型为String 而chengfa的类型为int 类型不匹配 编译报错
    1楼已经改正了这个程序,我就不再重复了!
      

  5.   

    因为你在循环体内返回的,所以循环只执行的1次,你要在循环体内对结果整合后再返回就可以了import java.util.Scanner;public class koujue {
    public static void main(String[] args) {
    System.out.print("请输入一个整数:");// 提示错误需要';'
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    Tools t = new Tools();
    System.out.println(t.chengfa(a));
    }
    }class Tools {
    public String chengfa(int x) {
    String s = "";
    for (int i = 1; i <= x; i++) {
    for (int j = 1; j <= i; j++) {
    s = s + j + "*" + i + "=" + j * i + "\t" + "\n";
    }
    }
    return s;
    }
    }