Advertisement
Guest User

Untitled

a guest
Oct 30th, 2014
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. class commandLine
  4. {
  5.  
  6. public static void main(String [] args)
  7. {
  8. int a[] = new int[args.length];
  9. int count = 0;
  10.  
  11. for (int i = 0; i<a.length;i++)
  12. {
  13. a[i] = Integer.parseInt(args[i]);
  14. count++;
  15. }
  16. System.out.println("Number of digits: " +count );
  17.  
  18. int large = a[0];
  19. int small = a[0];
  20. int num = 0;
  21. for (int j = 0; j<a.length; j++)
  22. {
  23. num = a[j] ;
  24.  
  25. if(num>large)
  26. {
  27. large=num;
  28. }
  29. if(num<small)
  30. {
  31. small=num;
  32. }
  33. }
  34. System.out.println("the largest is:" + large);
  35. System.out.println("Smallest no is : " + small);
  36.  
  37. boolean isPrime = true;
  38. for (int i = 2; i<a.length;i++){
  39. for (int j=2; j<i; j++)
  40. {
  41. if((i % j)== 0)
  42. {
  43. isPrime=false;
  44. break;
  45. }
  46. }
  47.  
  48. if(isPrime)
  49. {
  50. System.out.println(i + " is Prime");
  51. }
  52. isPrime = true;
  53. }
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement