返回列表 發帖
  1. package hi87;

  2. import java.util.Scanner;

  3. public class hi78 {

  4.           static Scanner keyboard = new Scanner(System.in);

  5.                  public static void main(String[] args) {
  6.                         test();
  7.                         test();
  8.                         test();
  9.                     }
  10.                     
  11.                     public static void test() {
  12.                             int s=1;
  13.                         System.out.print("Please enter one value =");
  14.                         int a=keyboard.nextInt();
  15.                         if(a>0&&a<=10)
  16.                         {
  17.                                 for(int i=a;i>=1;i--)
  18.                                 {
  19.                                         s=s*i;
  20.                                 }
  21.                                 System.out.println(a+"!="+s);
  22.                         }
  23.                         else
  24.                         {
  25.                                 System.out.println("Error,the value is out of range.");
  26.                         }
  27.                     }
  28.                 }
複製代碼

TOP

返回列表