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


The program starts by importing the Scanner class, which is used to read input from the user. The main method then creates a new Scanner object and prompts the user to enter three double-precision floating-point numbers using System.out.print() and in.nextDouble().

The program then uses if statements to check whether the numbers are in increasing order or decreasing order. If the first number is less than the second number, and the second number is less than the third number, the program prints "Numbers are in Increasing Order". If the first number is greater than the second number, and the second number is greater than the third number, the program prints "Numbers are in Decreasing Order". If neither of these conditions is true, the program prints "Neither Increasing or Decreasing Order".

Finally, the program prints the result using System.out.println().

Source Code

import java.util.Scanner;
public class Check_Incre_Decre
{
   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");
        }
    }
}

Output

Input First number: 86
Input Second number: 72
Input Third number: 563
Neither Increasing or Decreasing Order

Example Programs