Skip to content

Instantly share code, notes, and snippets.

@peter279k
Created May 24, 2017 11:04
Show Gist options
  • Save peter279k/a167e3f38ce5c728f2372eff07b9df4d to your computer and use it in GitHub Desktop.
Save peter279k/a167e3f38ce5c728f2372eff07b9df4d to your computer and use it in GitHub Desktop.
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