julial

Untitled

Feb 10th, 2016
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. //Julia Lamar
  2. //2-10-16
  3. //Prime Checker
  4. import java.util.*;
  5.  
  6. public class PrimeChecker
  7. {
  8. public static void main(String[] args)
  9. {
  10. Scanner input = new Scanner(System.in);
  11. System.out.print("Print a number: ");
  12. int num = inputInt();
  13. int counter = 0;
  14.  
  15. //loop ---- depend on the number the user gives
  16.  
  17. for (int i = 2; i < num; i++) {
  18. if (num % i == 0)
  19. counter++;
  20. }//endloop
  21.  
  22. if (num < 2)
  23. System.out.println("Please insert a number larger than 1");
  24.  
  25. else if (counter > 0)
  26. System.out.println(num +" is not prime!");
  27. else
  28. System.out.println(num +" is prime!");
  29.  
  30.  
  31. }//closemain
  32. }//closeclass
  33.  
  34. game plan:
  35. accumulator: total = 0;
  36. total < total + i
  37. counter
  38. mod = 0
Add Comment
Please, Sign In to add comment