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. // Initialize a counter for pace readings that exceed the threshold
  7. int count = 0;
  8.  
  9. // Loop through each pace reading
  10. for (int i = 0; i < input1; i++) {
  11. // Check if the current pace reading exceeds the threshold
  12. if (inputs[i] > input2) {
  13. count++; // Increment the counter
  14. }
  15. }
  16.  
  17. return count; // Return the total count
  18. }
  19. }
  20.  
  21. // Example usage
  22. public class Main {
  23. public static void main(String[] args) {
  24. UserMainCode userMainCode = new UserMainCode();
  25.  
  26. // Example 1
  27. int input1_1 = 5;
  28. int input2_1 = 7;
  29. int[] inputs_1 = {6, 8, 5, 10, 7};
  30. int result1 = userMainCode.paceDifference(input1_1, input2_1, inputs_1);
  31. System.out.println(result1); // Output: 2
  32.  
  33. // Example 2
  34. int input1_2 = 4;
  35. int input2_2 = 8;
  36. int[] inputs_2 = {9, 12, 7, 11};
  37. int result2 = userMainCode.paceDifference(input1_2, input2_2, inputs_2);
  38. System.out.println(result2); // Output: 3
  39. }
  40. }
Success #stdin #stdout 0.07s 54588KB
stdin
Standard input is empty
stdout
2
3