fork download
  1. import java.io.*;
  2. import java.util.*;
  3.  
  4. class UserMainCode {
  5. public int paceDifference(int input1, int input2, int[] inputs) {
  6. int count = 0;
  7.  
  8. // Count the pace readings greater than the threshold
  9. for (int pace : inputs) {
  10. if (pace > input2) {
  11. count++;
  12. }
  13. }
  14.  
  15. return count; // Return the count of exceeding paces
  16. }
  17. }
  18.  
  19. // Example usage
  20. public class Main {
  21. public static void main(String[] args) {
  22. UserMainCode umc = new UserMainCode();
  23.  
  24. // Example 1
  25. int input1_1 = 5;
  26. int input2_1 = 7;
  27. int[] inputs_1 = {6, 8, 5, 10, 7};
  28. System.out.println(umc.paceDifference(input1_1, input2_1, inputs_1)); // Output: 2
  29.  
  30. // Example 2
  31. int input1_2 = 4;
  32. int input2_2 = 8;
  33. int[] inputs_2 = {9, 12, 7, 11};
  34. System.out.println(umc.paceDifference(input1_2, input2_2, inputs_2)); // Output: 3
  35. }
  36. }
  37.  
Success #stdin #stdout 0.08s 54592KB
stdin
Standard input is empty
stdout
2
3