Created
May 24, 2017 11:04
-
-
Save peter279k/a167e3f38ce5c728f2372eff07b9df4d to your computer and use it in GitHub Desktop.
TQC+ JAVA
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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