Write a program that displays the negative subarraysnote


Java Programming:

Write a program that displays the "Negative subarrays".

Note: Subarrays are contiguous chunks of the main array. For example if the array is {1,2,3,5} then some of the subarrays are {1}, {1,2,3}, {2,3,5}, {1,2,3,5} etc. But {1,2,5} is not an subarray as it is not contiguous. A sub-array is "Negative" if all the integers in that sub-array is negative.

Your code will prompt for length of the array and it will read the N integers. Next, find all negative sub-arrays and display the results. The order of the subarrays is NOT important when you are displaying.

Example Run #1:

Enter array length: 5
Enter array elements: 1 -2 3 -4 5
Negative sub-arrays of the given array are: 
-2 
-4 

Example Run #2:

Enter array length: 6
Enter array elements: 6 -2 -8 -10 -7 5
Negative sub-arrays of the given array are: 
-2 
-8 
-10 
-7
-2 -8 
-8 -10 
-10 -7 
-2 -8 -10
-8 -10 -7
-2 -8 -10 -7

Example Run #3:

Enter array length: 10 
Enter array elements: -2 -5 -1 2 -3 0 1 -7 -4 -6
Negative sub-arrays of the given array are: 

 

-2 

-5 

-1 

-3 

-7 

-4 

-6 

-2 -5 

-5 -1 

-7 -4 

-4 -6 

-2 -5 -1 

-7 -4 -6 

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Write a program that displays the negative subarraysnote
Reference No:- TGS01161820

Expected delivery within 24 Hours