Negative subarrays

Assignment Help JAVA Programming
Reference no: EM13876428

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 

Reference no: EM13876428

Questions Cloud

Implementing a binary tree write a generic implementation : Implementing a Binary Tree Write a generic implementation of a binary tree class using an internal node class TreeBinUMUC and NodeTreeBin
Describe abell three dimensional business definition model : Describe Abell's three-dimensional business-definition model and explain where it can be utilized. Then, consider Reader's Digest Association, publisher of Reader's Digest, the largest circulation magazine in the world in 1992.
What is the firms horizon or continuing value : Hart Enterprises recently paid a dividend, Do, of $3.25. It expects to have non constant growth of 24% for 2 years followed by a constant rate of 8% thereafter. The firm's required return is 12% what is the firm's horizon, or continuing, value?
Consider risky portfolio-cash flow derived : Consider a risky portfolio. The end-of-year cash flow derived from the portfolio will be either $50,000 or $150,000, with equal probabilities of .5. The alternative risk less investment in T-bills pays 5%. If you require a risk premium of 10%, how mu..
Negative subarrays : 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 ..
Prepare a budgeted income statement : Cameron Parts has the following data from year 1 operations, which are to be used for developing year 2 budget estimates:
Sunk costs concept associated with making capital investment : Define the sunk costs concept associated with making capital investment decisions. Discuss why this concept is important for the investor to factor into the decision-making process.
Write a java program that stores these integers : 3. Write a java program that stores these integers 10, 20, 30, 40, 20 in an array named nums. Write the code to count all the occurrences of 20 and then display the count.
Define and discuss the concepts of risk and return : Define and discuss the concepts of risk and return. Also discuss the importance of portfolio diversification and its relationship to risk and return.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Recursive factorial program

Write a class Array that encapsulates an array and provides bounds-checked access. Create a recursive factorial program that prompts the user for an integer N and writes out a series of equations representing the calculation of N!.

  Hunt the wumpus game

Reprot on Hunt the Wumpus Game has Source Code listing, screen captures and UML design here and also, may include Javadoc source here.

  Create a gui interface

Create GUI Interface in java programing with these function: Sort by last name and print all employees info, Sort by job title and print all employees info, Sort by weekly salary and print all employees info, search by job title and print that emp..

  Plot pois on a graph

Write a JAVA program that would get the locations of all the POIs from the file and plot them on a map.

  Write a university grading system in java

University grading system maintains number of tables to store, retrieve and manipulate student marks. Write a JAVA program that would simulate a number of cars.

  Wolves and sheep: design a game

This project is designed a game in java. you choose whether you'd like to write a wolf or a sheep agent. Then, you are assigned to either a "sheep" or a "wolf" team.

  Build a graphical user interface for displaying the image

Build a graphical user interface for displaying the image groups (= cluster) in JMJRST. Design and implement using a Swing interface.

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Write a java windowed application

Write a Java windowed application to do online quiz on general knowledge and the application also displays the quiz result.

  Input pairs of natural numbers

Java program to input pairs of natural numbers.

  Create classes implement java interface

Interface that contains a generic type. Create two classes that implement this interface.

  Java class, array, link list , generic class

These 14 questions covers java class, Array, link list , generic class.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd