Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8990495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T22:30:44+00:00 2026-06-15T22:30:44+00:00

Here is my code: ArrayFunHouseTwo public class ArrayFunHouseTwo { //goingUp() will return true if

  • 0

Here is my code:

ArrayFunHouseTwo

public class ArrayFunHouseTwo
{
//goingUp() will return true if all numbers
//in numArray are in increasing order
//[1,2,6,9,23] returns true
//[9, 11, 13, 8]  returns false
public static boolean goingUp(int[] numArray)
{
    int num = 0;
    int numMinus = 0;
    for(int x = 1; x < numArray.length; x++){
        System.out.println(x);
        num = numArray[x];
        numMinus = numArray[x-1];

        if(num > numMinus){
            return true;
        }

    }
    return false;           
}

and the associated runner class:

import java.util.Arrays;

public class Lab14b
{
public static void main( String args[] )
{
    int[] one = {1,2,3,4,5,6,7,8,9,10};
    int[] two = {1,2,3,9,11,20,30};
    //add more test cases
    //int[] three = {9,8,7,6,5,4,3,2,0,-2};
    //int[] four = {3,6,9,12,15,18,21,23,19,17,15,13,11,10,9,6,3,2,1,0};

    System.out.println(Arrays.toString(one));
    System.out.println("is going Up ?  " + ArrayFunHouseTwo.goingUp(one));
    System.out.println(Arrays.toString(two));
    System.out.println("is going Up ?  " + ArrayFunHouseTwo.goingUp(two));
    //add more test cases
    //System.out.println(Arrays.toString(three));
    //System.out.println("is going Up ?  " + ArrayFunHouseTwo.goingUp(three));
    //System.out.println(Arrays.toString(four));
    //System.out.println("is going Up ?  " + ArrayFunHouseTwo.goingUp(four));

I’m wanting it to print out and thus, prove that it is reading though the whole array, but the only array it’s reading through is the third one and it will print all the values at position x or the value of x, depending on how I code the println() statement

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T22:30:46+00:00Added an answer on June 15, 2026 at 10:30 pm
    if(num > numMinus){
        return true;
    }
    

    This means that as soon as you find a number greater than its previous number, it will terminate the loop. What you want to do at this point is something like this.

    ...
        if(num <= numMinus){
            return false;
        }
    }
    return true;
    }
    

    edit: fixed the condition to <= basically you check consecutive numbers and if the numbers are equal or decreasing, you set a flag to false (indeed at this point you can return false)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

here's the code: import java.lang.System; import java.lang.Math; public class ArrayFunHouseTwo { public static int[]
Here a code to demonstrate an annoying problem: class A { public: A(): m_b(1),
Here is code example class A{ int i; public: A(int i) : i(i) {}
I have following code: public class readSensorsData extends Activity implements SensorListener { /** Called
The script is on jsfiddle here : CODE What it does at the moment
Ok the error is showing up somewhere in this here code if($error==false) { $query
Here is code my jqgrid editing through form. $(#DataEnergy).jqGrid('navGrid', '#pagergrid', {}, //options {editdata: {
Here my code, I need to insert into mysql database I have mysql,php,android 1)
Here is code from MSDN . I don't understand why the work isn't just
here is code for regular expression matching #include<iostream> #include<stdio.h> #include<string.h> using namespace std; int

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.