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


Introduction

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..


techstudy.org

Kindle Paperwhite High Resolution Display Tablet | Rs. 9999

  1. import java.util.Scanner;
  2. public class JavaExcercise {
  3. public static void main(String[] args)
  4. {
  5. Scanner in = new Scanner(System.in);
  6. System.out.print("Input first number: ");
  7. double num1 = in.nextDouble();
  8. System.out.print("Input second number: ");
  9. double num2 = in.nextDouble();
  10. System.out.print("Input third number: ");
  11. double num3 = in.nextDouble();
  12. if (num1 < num2 && num2 < num3)
  13. {
  14. System.out.println("Numbers are in Increasing order");
  15. }
  16. else if (num1 > num2 && num2 > num3)
  17. {
  18. System.out.println("Numbers are in Decreasing order");
  19. }
  20. else
  21. {
  22. System.out.println("Neither increasing or decreasing order");
  23. }
  24. }
  25. }

Result

java techstudy.org

     





Related Topics


Responses




Popular Posts

Facebook

Founded in 2016, Tech Study passionately delivers stylish and dynamic innovative information to programmer and technology lovers. http://www.techstudy.org/.