Skip to content

Instantly share code, notes, and snippets.

@peter279k peter279k/JPA03.java
Created May 24, 2017

Embed
What would you like to do?
TQC+ JAVA
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 sum = 1;
if(num > 10 || num <= 0) {
System.out.println("Error, the value is out of range.");
} else {
for(int index=1;index<=num;index++) {
sum *= index;
}
System.out.println(num + "!: " + sum);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.