Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Only Java please. NMONDO package console_apps; 2 30 import java.util.Scanner:0) 6 1 public class GetFilteredSeqApp { 8 90 public static void main(String[] args) { 10

image text in transcribed
image text in transcribed
image text in transcribed
Only Java please.
NMONDO package console_apps; 2 30 import java.util.Scanner:0) 6 1 public class GetFilteredSeqApp { 8 90 public static void main(String[] args) { 10 Scanner inrut = new Scanner(System.in); 11 12 /* Prompt the user for an array of numbers. */ 13 System.out.println("How many numbers do you want to input?"); 14 int howMany = input.nextInt(); 15 int[] numbers = new int [howMany); 16 int i = 0; 17 while(i "); 9 input.close(); -1 -2 -3 } 0 * * Input parameters: numbers': an array of integers : an integer (which may or may not exist in 'numbers) * Refer to you lab instructions for what the method should return. */ public static int[] getFilteredSeq(int[] numbers, int n) { int() result = null; /* Your implementation of this method starts here. * Recall from Week 1's tutorial videos: * 1. No System.out.println statements should appear here. Instead, an explicit, final return statement is placed for you. * 2. No Scanner operations should appear here (e.g., input.nextInt()). Instead, refer to the input parameters of this method. * /* Your implementation ends here. */ return result; Problem. You are asked to implement a utility method which takes as input an array (say numbers) of integers and an integer (say n). Note that na may or may not exist in numbers. The utility method returns another array containing all elements in numbers that are not equal to n. For example, if the input n is 3 and the input array numbers is: Then the output or returned array is: Note that the length of the output array corresponds the number of elements in the input array that are not equal to n, meaning that if the input array is empty, or if n does not exist in the input array, then the output array should be just the same as the input array. Also, the output array should preserve the order in which elements appear in the input array. For example, in the above example, elements in the output array appear in the order of 1 followed by 2 and then by 4, which is reflected in the input array. Testing. Your goal is to first pass all tests related to this method in the JUnit test class TestUtilities. You are encouraged to write additional JUnit tests. These tests document the expected values on various cases: study them while developing your code. However, use the console application class GetFilteredSe App if you wish (e.g., use the input and expected values from the JUnit tests). Here is an example run: How many numbers do you want to input? 5 Enter input 1: 3 Enter input 2: 1 Enter input 3: 2 Enter input 4: 3 Enter input 5: 4 Which number do you wish to filter from the input numbers? 3 Todo. Implement the Utilities.getFilteredSeq method. See the comments there for the input parameters and requirements

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional SQL Server 2012 Internals And Troubleshooting

Authors: Christian Bolton, Justin Langford

1st Edition

1118177657, 9781118177655

Students also viewed these Databases questions

Question

What is your intention in communicating this message?

Answered: 1 week ago