/******
檔名:JPA03.java
題目:TQC+ JAVA6物件導向程式設計 參考答案
時間:2015/06
作者:fang shi mai
******/
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()
{
int N;
int sum=1;
System.out.print("Please enter one value: ");
N=keyboard.nextInt();
if(N>=1 && N<=10)
{
for(int i=1;i<=N;i++)
sum*=i;
System.out.printf("%d!: %d\n",N,sum);
}
else
{
System.out.println("Error, the value is out of range.");
}
}
}
305迴圈階乘計算
訂閱:
文章 (Atom)
沒有留言:
張貼留言