Jc.java: 3: required < identifier >
Static int getFactorial (int i) {
^
Jc.java: 3: method declaration invalid ; need a return type
Static int getFactorial (int i) {
^
2 errors
procedures are as follows :
import java.util.Scanner;
public class Jc {
Static int getFactorial (int i) {
if (i <0) return -1;
else if (i == 0 | | i == 1) return 1;
else retun (i * getFactorial (i-1));
}
public static void main (String [] args) {
System.out.println ("input a number");
Scanner m = new Scanner (System.in);
int ret = getFactorial (m);
if (ret = -1) System.out.println ("errow number!");
else System.out.println (+ m + "!" + "=" + (m.getFactorial));
return 0;
}
}
------ Solution ----------------------------------- ---------
now OK to write the code to get what notepad
getFactorial this function definition receives int type argument , you look at your pass into
------ Solution ------------------ Gesha --------------------------
recommend using eclipse
------ Solution -------- ------------------------------------
eclipse, everyone is using Oh
------ Solution - -------------------------------------------
everyone is using Oh , eclipse!
------ For reference only -------------------------------------- -
I new dishes , the teacher said first with dos I pass a scanner looks like I do not know what type of object , so it should be how ...
------ For reference wait I only ---------------------------------------
treatments
------ For reference only ------------------------------------ ---
import java.util.Scanner;
public class Test{
static int getFactorial(int i){
if (i<0)
return -1;
else if(i==0||i==1)
return 1;
else
return (i*getFactorial(i-1));
}
public static void main(String[] args){
System.out.println("input a number ");
Scanner m=new Scanner(System.in);
int intarg = m.nextInt();
int result=getFactorial(intarg);
if (result==-1)
System.out.println("errow number!");
else
System.out.println(intarg+"!"+"="+result);
}
}
------ For reference only ----------------------------- ----------
you still use an editor to it a bunch of errors
------ For reference only ----------- ----------------------------
Thank you ! ! ! So what you are using the editor ?
没有评论:
发表评论