Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Java program help please Create a main method, and create a 2D integer array called data , with a size of five (5) by five
Java program help please
- Create a main method, and create a 2D integer array called data, with a size of five (5) by five (5). Ask the user to input the values for this array (Scanners nextInt).
- Create a method called LongestPositiveSeries, that takes in a 2D array and finds the length of the longest continuous series of positive numbers in it.
- For example, if we had an array like this:
0 | 1 | 2 | 3 | 4 |
5 | -1 | -5 | -5 | 5 |
3 | -2 | 56 | 25 | -15 |
0 | 5 | 5 | 0 | 324 |
46 | 25 | 0 | 0 | 0 |
- The length would be 5. For this problem, 0 is considered non-negative and not positive, so we start counting from index [0, 1] (which is 1) to [1, 0] (which is 5) and end at index [1, 1] (which is 1).
- Hint: Consider using a basic linear search and modifying it to keep track of the current positive streak of numbers.
- Call that method in your main, for the array data.
4. Print out the returned result from your method in your main, along with the content of data.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started