Java: An Introduction to Problem Solving and Programming (7th Edition)
Java: An Introduction to Problem Solving and Programming (7th Edition)
7th Edition
ISBN: 9780133766264
Author: Walter Savitch
Publisher: PEARSON
bartleby

Videos

Expert Solution & Answer
Book Icon
Chapter 7, Problem 8E

Explanation of Solution

Method definition for “isStrictlyIncreasing”:

/* Method definition for "isStrictlyIncreasing" method */

public static boolean isStrictlyIncreasing(double[] in)

{

    //Assign answer to "true"

    boolean answer = true;

    /* Check each array element using "for" loop */

    for(int i = 0; i < (in.length - 1); i++)

    {

/* If each value in the given array is less than the value before it, then */

        if(in[i+1] <= in[i])

            /* Assign answer to "false" */

            answer = false;

    }

    //Finally returns the value of answer

    return answer;

}

Complete code:

The complete code for implementing the method “isStrictlyIncreasing” is given below:

//Define "SampleArray" class

public class SampleArray

{

    //Define main function

    public static void main(String[] args)

    {

        //Initializes the values for "array1"

        double[] array1 = {2.18, 4.8, 6.2, 8.14, 10.2};

        //Initializes the values for "array2"

double[] array2 = {8.2, 6.43, 12.10, 3.46, 18.4, 6.2, 20.8, 15.42, 13.12, 32.84};

        //Display given statement

        System.out.print("Result of array1: ");

/* Call the method "isStrictlyIncreasing" with argument of "array1" */

System.out.println(isStrictlyIncreasing(array1));

        //Display given statement

        System.out.print("Result of array2: ");

/* Call the method "isStrictlyIncreasing" with argument of "array2" */

System.out.println(isStrictlyIncreasing(array2));

    }

/* Method definition for "isStrictlyIncreasing" method */

public static boolean isStrictlyIncreasing(double[] in)

    {

        //Assign answer to "true"

        boolean answer = true;

        /* Check each array element using "for" loop */

        for(int i = 0; i < (in...

Blurred answer
Students have asked these similar questions
No AI solutions please
No AI solutions please
No AI solutions please

Chapter 7 Solutions

Java: An Introduction to Problem Solving and Programming (7th Edition)

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Cengage Learning
Definition of Array; Author: Neso Academy;https://www.youtube.com/watch?v=55l-aZ7_F24;License: Standard Youtube License