Assume you are given an int variable named nPositive and a 2-dimensional array of ints that has been created and assigned to a2d. Write some statements that compute the number of all the elements in the entire 2-dimensional array that are greater than zero and assign the value to nPositive.

LANGUAGE: JAVA

CHALLENGE:

Assume you are given an int variable named nPositive and a 2-dimensional array of ints that has been created and assigned to a2d. Write some statements that compute the number of all the elements in the entire 2-dimensional array that are greater than zero and assign the value to nPositive.

SOLUTION:

The Bad News: The content you are trying to access is only available to members.

The Good News: You too can be a member, simply Click Here.

Already a member?

Posted in ,

8 Comments

  1. AL on November 9, 2016 at 11:50 pm

    nPositive = 0;
    for (int i=0; i< a2d.length; i++){
    for (int j=0; j 0)
    nPositive++;
    }
    }

  2. AlanW on March 14, 2017 at 10:35 pm

    nPositive = 0;
    for (int i = 0; i < a2d.length; i++)
    {
    for (int j = 0; j 0)
    {
    nPositive++;
    }
    }
    }

  3. AlanWo on March 14, 2017 at 10:36 pm

    nPositive = 0;
    for (int i = 0; i < a2d.length; i++)
    {
    for (int j = 0; j 0)
    {
    nPositive++;
    }
    }
    }

    • AlanWo on March 14, 2017 at 10:36 pm

      nPositive = 0;
      for (int i = 0; i < a2d.length; i++)
      {
      for (int j = 0; j 0)
      {
      nPositive++;
      }
      }
      }

  4. AlanWon on March 14, 2017 at 10:37 pm

    nPositive = 0;
    for (int i = 0; i < a2d.length; i++)
    {
    for (int j = 0; j 0)
    {
    nPositive++;
    }
    }
    }

  5. hotrodjeremy on April 24, 2017 at 3:40 pm

    nPositive = 0;
    for (int i = 0; i < a2d.length; i++)
    for (int j = 0; j 0)
    nPositive++;

  6. j p on July 28, 2017 at 12:15 am

    try this one:

    nPositive = 0;
    for (int i=0; i<a2d.length; i++){
    for (int j=0; j 0){
    nPositive++;
    }
    }
    }

  7. shusma kafle on November 23, 2017 at 7:10 pm

    nPositive = 0;
    for (int i=0; i<a2d.length; i++){
    for (int j=0; j 0){
    nPositive++;
    }
    }
    }

Leave a Comment

You must be logged in to post a comment.