Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please help me for this assignment!! ASAP. This is JAVA using in ECLIPSE. JUST PART 1 java in eclipse Part 1: class NConsecutive Implement the

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

Please help me for this assignment!! ASAP.

This is JAVA using in ECLIPSE.

JUST PART 1
java in eclipse
image text in transcribed
Part 1: class NConsecutive Implement the hasnConsecutive () method to test whether the supplied array has a specified number of consecutive, same-valued elements. public static boolean hasConsecutive (int[] values, int runLength) You need to handle the case where there are no elements in the array - there's nothing to match so you can't find n-consecutive so return false. Similarly, you already know the answer (also false) if the length of the array is smaller than the number of elements you're looking for. The JUnit tests are in NConsecutive DMRTests.java. I included sample output below. Part 2: class NConsecutive UI Write a test program that prompts the user to enter a series of integers and displays whether the series contains runLength consecutive same-valued elements. Your program's main() must prompt the user to enter the input size (the number of values in the series - dynamically allocate an appropriately sized array), the number of consecutive same-valued elements to match, and the sequence of integer values to check. The return value indicates whether at least one run of runLength elements exists in values. Implement the test program in the NConsecutiveUI class (the main() method is already in place). import statements for Scanner and hasnConsecutive () are already in place. Two sets of output from NConsecutive DMRTests follow: 1. test results of a correct implementation 2. test results of NConsecutive with all stub responses (from the template I provided to you) Expected summary output (on console) from NConsecutiveDMRTests - correct implementation: Detailed log in: C:\- Java Workspace - Demo\CS II -- DMR -- Lab 01 (2020-1sp)\test- logs \NConsecutiveDMRTests-2020-01-26-155911. log Starting tests of class NConsecutive [1] Starting tests of has Consecutive() [1] Successfully completed 18 of 18 tests (100%) of hasnConsecutive() Summary Test Results [1] Successfully completed 18 of 18 tests (100%) of has Consecutive() Successfully completed 18 of 18 tests (100%) attempted for class NConsecutive Expected detailed output (in named log) from NConsecutiveDMRTests - correct implementation: Detailed log in: C:\- Java Workspace - Demo\CS II -- DMR -- Lab 01 (2020-1sp)\test- logs \NConsecutive DMRTests -2020-01-26-155911. log Starting tests of class NConsecutive Successfully completed 18 OF 18 tests (100%) attempted for class Nconsecutive Expected detailed output (in named log) from NConsecutive DMRTests - correct implementation: Detailed log in: C:\- Java Workspace - Demo\CS II -- DMR -- Lab 01 (2020-1sp) \test- logs\NConsecutive DMRTests-2020-01-26-155911.log Starting tests of class NConsecutive [1] Starting tests of hasConsecutive() [1, 1] Testing: hasConsecutive( [1, 1], 1) expect: true actual: true [1, 1] Test passed [1, 2] Testing: hasConsecutive [1], 1) expect: true actual: true [1, 2] Test passed [1, 3 s] Testing: has Consecutive [1, 2, 3], 2) expect: false actual: false [1, 3 s] Test passed [1, 4 s] Testing: hasConsecutive( [1, 1, 1, 1], 2) expect: true actual: true [1, 4 s] Test passed [1, 5 s) Testing: hasConsecutive (1, 1, 1, 1], 3 ) expect: true actual: true [1, 5 s] Test passed [1, 6 s] Testing: hasConsecutive( [1, 1, 1, 1], 4) expect: true actual: true [1, 6 s] Test passed [1, 7 s) Testing: hasNConsecutive( [1, 1, 1, 1], 5) expect: false actual: false [1, 7 s] Test passed [1, 8 s] Testing: hasConsecutive( [1, 1, 2, 3], 2) expect: true actual: true [1, 8 s] Test passed 11, 9 s] Testing: has Consecutive( (1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3), 14 ) expect: true actual: true [1, 9 s] Test passed [1, 10 s] Testing: has Consecutive( [1, 2, 3, 4, 4], 2) expect: true actual: true 70 / 8 9 * Implement a method ({@code has Consecutive() }) to test whether the user entered a user-specified number of consecutive, same-valued numbers. * @author * Aversion 1.0.0 2020-01-26 initial version per assignment public class NConsecutive * Test whether {@code values) has a specified number of consecutive, same-valued elements * @param values The array of numbers to check for a sequence of consecutive, same-valued elements * @param runLength The number of occurrences we are looking for in {@code values} * @return {@code true} if at least one sequence of {@code runLength}, same -valued entries exists; {@code false} otherwise HV/ end hasNConsecutive() * You can use the main() method to test your implementation of * has Consecutive() * @param args -unused public static void main(String[] args) Part 1: class NConsecutive Implement the hasnConsecutive () method to test whether the supplied array has a specified number of consecutive, same-valued elements. public static boolean hasConsecutive (int[] values, int runLength) You need to handle the case where there are no elements in the array - there's nothing to match so you can't find n-consecutive so return false. Similarly, you already know the answer (also false) if the length of the array is smaller than the number of elements you're looking for. The JUnit tests are in NConsecutive DMRTests.java. I included sample output below. Part 2: class NConsecutive UI Write a test program that prompts the user to enter a series of integers and displays whether the series contains runLength consecutive same-valued elements. Your program's main() must prompt the user to enter the input size (the number of values in the series - dynamically allocate an appropriately sized array), the number of consecutive same-valued elements to match, and the sequence of integer values to check. The return value indicates whether at least one run of runLength elements exists in values. Implement the test program in the NConsecutiveUI class (the main() method is already in place). import statements for Scanner and hasnConsecutive () are already in place. Two sets of output from NConsecutive DMRTests follow: 1. test results of a correct implementation 2. test results of NConsecutive with all stub responses (from the template I provided to you) Expected summary output (on console) from NConsecutiveDMRTests - correct implementation: Detailed log in: C:\- Java Workspace - Demo\CS II -- DMR -- Lab 01 (2020-1sp)\test- logs \NConsecutiveDMRTests-2020-01-26-155911. log Starting tests of class NConsecutive [1] Starting tests of has Consecutive() [1] Successfully completed 18 of 18 tests (100%) of hasnConsecutive() Summary Test Results [1] Successfully completed 18 of 18 tests (100%) of has Consecutive() Successfully completed 18 of 18 tests (100%) attempted for class NConsecutive Expected detailed output (in named log) from NConsecutiveDMRTests - correct implementation: Detailed log in: C:\- Java Workspace - Demo\CS II -- DMR -- Lab 01 (2020-1sp)\test- logs \NConsecutive DMRTests -2020-01-26-155911. log Starting tests of class NConsecutive Successfully completed 18 OF 18 tests (100%) attempted for class Nconsecutive Expected detailed output (in named log) from NConsecutive DMRTests - correct implementation: Detailed log in: C:\- Java Workspace - Demo\CS II -- DMR -- Lab 01 (2020-1sp) \test- logs\NConsecutive DMRTests-2020-01-26-155911.log Starting tests of class NConsecutive [1] Starting tests of hasConsecutive() [1, 1] Testing: hasConsecutive( [1, 1], 1) expect: true actual: true [1, 1] Test passed [1, 2] Testing: hasConsecutive [1], 1) expect: true actual: true [1, 2] Test passed [1, 3 s] Testing: has Consecutive [1, 2, 3], 2) expect: false actual: false [1, 3 s] Test passed [1, 4 s] Testing: hasConsecutive( [1, 1, 1, 1], 2) expect: true actual: true [1, 4 s] Test passed [1, 5 s) Testing: hasConsecutive (1, 1, 1, 1], 3 ) expect: true actual: true [1, 5 s] Test passed [1, 6 s] Testing: hasConsecutive( [1, 1, 1, 1], 4) expect: true actual: true [1, 6 s] Test passed [1, 7 s) Testing: hasNConsecutive( [1, 1, 1, 1], 5) expect: false actual: false [1, 7 s] Test passed [1, 8 s] Testing: hasConsecutive( [1, 1, 2, 3], 2) expect: true actual: true [1, 8 s] Test passed 11, 9 s] Testing: has Consecutive( (1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3), 14 ) expect: true actual: true [1, 9 s] Test passed [1, 10 s] Testing: has Consecutive( [1, 2, 3, 4, 4], 2) expect: true actual: true 70 / 8 9 * Implement a method ({@code has Consecutive() }) to test whether the user entered a user-specified number of consecutive, same-valued numbers. * @author * Aversion 1.0.0 2020-01-26 initial version per assignment public class NConsecutive * Test whether {@code values) has a specified number of consecutive, same-valued elements * @param values The array of numbers to check for a sequence of consecutive, same-valued elements * @param runLength The number of occurrences we are looking for in {@code values} * @return {@code true} if at least one sequence of {@code runLength}, same -valued entries exists; {@code false} otherwise HV/ end hasNConsecutive() * You can use the main() method to test your implementation of * has Consecutive() * @param args -unused public static void main(String[] args)

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

Step: 3

blur-text-image

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

Oracle PL/SQL Programming Database Management Systems

Authors: Steven Feuerstein

1st Edition

978-1565921429

More Books

Students also viewed these Databases questions

Question

How can Trip 7 prevent future supply chain uncertainties?

Answered: 1 week ago