Java 如何使用printwriter连接不同的方法?

Java 如何使用printwriter连接不同的方法?,java,Java,我已经执行了以下方法。findSum有效,阶乘和有多少不起作用 我的方法是错误的还是我的主程序中缺少了什么 芬德萨姆 主程序 您可以像这样调用其他方法,并且不在方法中使用PrintWriter,只保留用于执行某项操作的方法,而不使用结果 public static int factorial(int n){ int max = 1; for (int p=2; p<=n ; p++){ max *= p; } return max; } 请

我已经执行了以下方法。findSum有效,阶乘和有多少不起作用

我的方法是错误的还是我的主程序中缺少了什么

芬德萨姆 主程序
您可以像这样调用其他方法,并且不在方法中使用PrintWriter,只保留用于执行某项操作的方法,而不使用结果

public static int factorial(int n){
    int max = 1;
    for (int p=2; p<=n ; p++){
        max *= p;
    }
    return max;
}

请缩进好你的代码你从来没有调用过factorial,你希望它们有多少个甚至如何执行?对不起,我对java真的很陌生。那么,主程序中缺少了什么东西吗?编写这段代码不是很新^^你调用findSum以便执行它,其他的则不是。howmanyeven的目标是什么?
public static int factorial(int n,PrintWriter output){
  int max=1;
  for (int p=2;p<=n;p++){
    max*=p;
  }
  if (n>0){
    output.println(max+"! is "+n);
  }else{
    output.println("it is not possible to calculate the factorial");
  }
  return max;
}
public static int howmanyeven(int z,PrintWriter output){
  int max=z;
    while (z%2==0){
      output.println("There is/are "+z+" even number(s)");
      output.close();
    }
  return max;
}
public static void main(String[]args)throws FileNotFoundException{
  Scanner input =new Scanner(System.in);
  System.out.println("Enter VAL. -1 to end:");
  int val,a,b,c,count=0;
  val=input.nextInt();
  PrintWriter output=new PrintWriter("Sum.txt");
  while (val!=-1){
    System.out.println("Enter a,b,c:");
    a=input.nextInt();
    b=input.nextInt();
    c=input.nextInt();
    int max;
    max=findSum(a,b,c,output);
    output.println("The three original integers are "+a+" "+b+" "+c+" \n"+max+" is the sum\n");
    System.out.println("Enter VAL. -1 to end:");
    val=input.nextInt();
    count++;
  }
  output.println(count+" sets of three data were entered and processed");
  output.close();
  input.close();
  }
}
public static int factorial(int n){
    int max = 1;
    for (int p=2; p<=n ; p++){
        max *= p;
    }
    return max;
}
public static List<Integer> howmanyeven(int... values){
    List<Integer> res = new ArrayList<>();
    for(int i=0; i<values.length; i++){
        if(values[i]%2 == 0){
            res.add(values[i]);
        }
    } 
    return res;
}
max = findSum(a, b, c);
output.println("The three original integers are "+a+" "+b+" "+c+" \n" max+" is the sum\n");

int facto = factorial(max)
output.println("Factorial of "+ max + "is" + facto);

List<Integer> even = howmanyeven(a,b,c)
output.println("The evens are "   + even)