System.out.println("Error,the value is out of range.");
}
}
}
複製代碼
作者: 巫沛庭 時間: 2018-7-17 19:08
import java.util.Scanner;
public class JPA03 {
static Scanner keyboard = new Scanner(System.in);
public static void main(String[] args) {
test();
test();
test();
}
public static void test() {
System.out.print("Please enter one value: ");
int num=keyboard.nextInt();
int num1,num2=1;
if(num>=1 && num<=10)
{
for(num1=1;num1<=num;num1++)
{
num2=num1*num2;
}
System.out.print(num+"! = "+num2);
}
else{
System.out.print("Error. the value is out of the range. ");
}
}
}
複製代碼
作者: 巫晉宇 時間: 2018-7-17 19:11
package terror;
import java.util.Scanner;
public class rrrrr {
static Scanner e = new Scanner(System.in);
public static void main(String[] args) {
// TODO 自動產生的方法 Stub
test();
test();
test();
test();
}
private static void test() {
// TODO 自動產生的方法 Stub
int p = 1;
System.out.println("Please enter one value:");
int o=e.nextInt();
if(o>=1 && o<=10)
{
for(int k=1;k<=o;k++)
{
p=p*k;
}
System.out.println(o+"!="+p);
}
else
{
System.out.println("Error,the value is out of range.");
}
}