Q:

Write a java program that accepts three numbers from the user and check if numbers are in “increasing” or “decreasing” order.

0

Write a java program that accepts three numbers from the user and check if numbers are in “increasing” or “decreasing” order.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

In this demo I have used NetBeans IDE 8.2 for debugging purpose. But you can use any java programming language compiler as per your availability..

import java.util.Scanner;
public class JavaExcercise {
   public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        System.out.print("Input first number: ");
        double num1 = in.nextDouble();
        System.out.print("Input second number: ");
        double num2 = in.nextDouble();
       System.out.print("Input third number: ");
        double num3 = in.nextDouble();
        if (num1 < num2 && num2 < num3)
        {
            System.out.println("Numbers are in Increasing order");
        }
        else if (num1 > num2 && num2 > num3)
        {
            System.out.println("Numbers are in Decreasing order");
        }
        else
        {
            System.out.println("Neither increasing or decreasing order");
        }
    }
}

Result:

Input first number: 600

Input second number: 500

Input third number: 300

Numbers are in Decreasing order

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Write a Java program that determines a student’s... >>
<< Write a Java program that accepts three numbers an...