Question: In a program, write a method that accepts two arguments: an array of integers and a number n. The method should print all of the

In a program, write a method that accepts two arguments: an array of integers and a number n. The method should print all of the numbers in the array that are greater than the number n (in the order that they appear in the array, each on their own line). In the same file, create a main method and call your function using the following data sets: The array {1, 5, 10, 2, 4, -3, 6} and the number 3. The array {10, 12, 15, 24} and the number 12.

My code:

public class LargerThanN { public static void print(int[] array,int n) { for(int i=0; in) System.out.println(array[i]); } System.out.println(); }

public static void main(String[] args) { int[] array1 = {1,5,10,2,4,-3,6}; int num1=3; print(array1,num1); int[] array2 = {10, 12, 15, 24}; int num2 = 12; print(array2, num2); } }

My programming lab does not want extra lines between the output. What am I doing wrong? How do I fix it?

In a program, write a method that accepts two arguments: an array

Failed Test Run The contents of your standard output is incorrect. Attention: the difference between your stdout and the expected stdout is just a question of spacing. Standard Output Hide Invisibles Your Code's Actual Result: Expected Result: 54 104 10 6.4 15 24.4 15. 24

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!