Write a java program that accepts three numbers from the user and check if numbers are in “increasing” or “decreasing” order.
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
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
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..
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