- package hi87;
- import java.util.Scanner;
- public class hi78 {
- static Scanner keyboard = new Scanner(System.in);
- public static void main(String[] args) {
- test();
- test();
- test();
- }
-
- public static void test() {
- int s=1;
- System.out.print("Please enter one value =");
- int a=keyboard.nextInt();
- if(a>0&&a<=10)
- {
- for(int i=a;i>=1;i--)
- {
- s=s*i;
- }
- System.out.println(a+"!="+s);
- }
- else
- {
- System.out.println("Error,the value is out of range.");
- }
- }
- }
複製代碼 |