Mrvideogame

(Hint, Hint)

Jan 13th, 2014
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Factory {
  4.  
  5. public static void main(String[] args) {
  6.  
  7. Scanner myScanner = new Scanner(System.in);
  8.  
  9. //Set variables
  10. int usernumber = myScanner.nextInt();
  11. int loop = usernumber;
  12. int finalAnswer = usernumber;
  13. int multiply = 1;
  14.  
  15. //Ask the user for a number between 1 and 20
  16. System.out.println("Please enter a number between 1 and 20(inclucive)");
  17.  
  18. //Here we loop round and round we go....
  19. while(--loop > 0) {
  20. finalAnswer = finalAnswer * multiply++;
  21. System.out.println(finalAnswer);
  22. }
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment