Advertisement
Guest User

Untitled

a guest
Oct 16th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. int iterations = 0, count2 = 0, j = 1, max = 0, min = 0, userInt = 0,
  2. sum = 0, even = 0,
  3. odd = 0;
  4.  
  5. double mean = 0;
  6.  
  7. do {
  8.  
  9. System.out.println("Enter the number of loop iterations required: ");
  10. iterations = sc.nextInt();
  11.  
  12. if (iterations <=0)
  13.  
  14. System.out.println("Enter an integer greater than 0");
  15.  
  16. } while (iterations <= 0);
  17.  
  18.  
  19. for (int i = 1; i <= iterations; i++) {
  20. count2 = iterations - (iterations - j);
  21.  
  22. System.out.println("\n\nenter integer " + count2);
  23. userInt = sc.nextInt();
  24.  
  25. sum += userInt;
  26. mean = (double)sum/(double)count2;
  27. System.out.println("mean of input " + count2 + " is: " + mean);
  28.  
  29.  
  30. if (count2 == 1) {
  31. max = userInt;
  32. min = userInt;
  33. }
  34. else {
  35. if (userInt > max) {
  36. max = userInt;
  37. }
  38. if (userInt < min) {
  39. min = userInt;
  40. }
  41. }
  42.  
  43. System.out.println("max value is: " + max );
  44.  
  45.  
  46. System.out.println("min value is: " + min);
  47.  
  48. if ((userInt % 2) == 0) {
  49. even += 1;
  50. }
  51.  
  52. else {
  53. odd += 1;
  54. }
  55.  
  56. System.out.println("even count: " + even);
  57.  
  58. System.out.println("odd count " + odd);
  59.  
  60.  
  61. j++;
  62.  
  63. }
  64.  
  65. sc.close();
  66.  
  67.  
  68. }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement